它们会立即回滚吗?它们会在一段时间后回滚吗?他们是否处于未承诺状态?
如果使用连接池并且只是重置连接,行为是否相同?
如何将CommandTimeout添加到web.config中的连接字符串?
我试过了:
<add name="ConnectionString" connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=sa;Password=sa@123;Connect Timeout=200" providerName="System.Data.SqlClient"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
还有这个:
<add name="MyProject.ConnectionString"
connectionString="Data Source=127.0.0.1;Initial Catalog=MyDB;Persist Security Info=True;CommandTimeout=60;User ID=sa;Password=saPassw0rd"
providerName="System.Data.SqlClient" />
Run Code Online (Sandbox Code Playgroud)
但它并没有为我工作.
谢谢
我在用 Microsoft.SqlServer.Management.Smo.
我的代码:
Server server = new Server(new ServerConnection( new SqlConnection(ConnectionString));
server.ConnectionContext.ExecuteNonQuery(script);
Run Code Online (Sandbox Code Playgroud)
我想像CommandTimeout平常那样设置它SQLCommand
请告诉我如何设置CommandTimeout查询运行Microsoft.SqlServer.Management.Smo.Server
如何从 SQL Server 中的连接字符串进行配置CommandTimeout(不是Connect Timeout)?
我以为很容易找到,但显然不是。下面我添加了CommandTimeout=60。它似乎没有破坏任何东西,但我不知道它是否真的有效(而且我找不到这方面的文档)
Data Source=someplace.com;Initial Catalog=MyDB;CommandTimeout=60;User Id=someID;Password=secret;
Run Code Online (Sandbox Code Playgroud)