Hi,
Here is my code on how i connect to my database
Dim rst As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim vresponse As String
' On Error GoTo err_proc
Try
conn.Open(GetConn(getconnid))
Select Case getmode
Case 0 'execute then return first field
rst = conn.Execute(getsql)
If rst.EOF = False And rst.BOF = False Then
Try
vresponse = IIf(IsDBNull(rst.Fields.Item(0).Value), "", rst.Fields.Item(0).Value)
' vresponse = rst.Fields.Count
Catch ex As Exception
vresponse = "Error :" + ex.Message
End Try
End If
Case 1 'execute only
If bTransactional = True Then
conn.BeginTrans()
End If
conn.Execute(getsql)
vresponse = "OK"
If bTransactional = True Then
conn.CommitTrans()
End If
End Select
Return vresponse.Trim
* line 1)
rst = Nothing
conn = Nothing
Exit Function
supposed to be *line 1) terminates the connection/session form SQL server. But when i check to the SQL Query Analyzer, there is still some connections related to this command. So when i run again this commands, it creates another connection. How can i terminate/end my sessions in SQL.
Thanks
You can use KILL command, take a look at this link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_kf-kz_1zos.asp
没有评论:
发表评论