VBA ODBC Update
- by Soo
This is the code I'm using to update an SQL database:
Public Sub main()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
cnn.Open "ConnectionName"
rst.ActiveConnection = cnn
rst.CursorLocation = adUseServer
rst.Source = "Update Table ..."
rst.Open
Set rst = Nothing
Set cnn = Nothing
End Sub
What I want to know is if and how I should deal with the rst object after opening it. Do I close it? When I try doing rst.Close, I get the error: "Operation is not allowed when the object is closed". The code works fine without rst.Close, I'm wondering if there are any dangers to not closing the object.