我想在VB.NET中增加SqlCommand.CommandTimeout, 我想把它提高到三分钟。
我试试这个:
Public Function SQL_send(ByVal Command As String) As String
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim dr As SqlDataReader
Dim databases As New ArrayList
'declaring the objects
myConnection = New SqlConnection("server=" & sql_server & ";uid=" & sql_user & ";pwd=" & sql_pasword & ";database=" & sql_database)
'establishing connection. you need to provide password for sql server
myConnection.Open()
'opening the connection
myCommand = New SqlCommand(Command, myConnection)
myCommand.CommandTimeout = 300
'executing the command and assigning it to connection
myCommand.ExecuteScalar()
myConnection.Close()
Console.WriteLine(Command & vbCrLf)
End Function
但是它没有用,它停留了30秒。
有人有想法吗?谢谢!
问候亚历克斯