0
我应该首先声明,我认为这个问题的答案是NO,但我想要求确定.....如果您在函数内部打开sqlconnection(使用USING块),并在到达块结束之前从该函数返回,那么该连接是否会被正确处理?在处理sqlconnection之前从函数返回
例如:
Public Function Myfunction() As Boolean
Dim ConnectionString As String = "connectionstring goes here"
Dim sql As String = "SELECT * FROM mytable"
Using connection As New SqlClient.SqlConnection(ConnectionString)
Using command As New SqlClient.SqlCommand(sql, connection)
connection.Open()
Using reader As SqlClient.SqlDataReader = command.ExecuteReader
While reader.Read
Return True
End While
End Using
End Using
End Using
Return False
End Function
将上述连接被布置如果适当地执行返回真实线的?
试试吧,找出来。 – Servy