Sub cmdUpdateRecord_Click()
' Declare and instantiate the object variable
Dim cnStateUBookstore As Connection
Dim sSQL As String
Set cnStateUBookstore = New Connection
' Establish a connection
With cnStateUBookstore
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;" & _
"Data Source=MSERIES1;" & _
"Initial Catalog=StateUBookstore"
.Open
End With
' Build the SQL command
sSQL = "UPDATE Students SET MajorID = 4 WHERE StudentID = 3"
' Execute the SQL command
cnStateUBookstore.Execute sSQL
End Sub