Hi Guys,
I am having problems getting the following code to update an Access table. I
get the following error:-
An unhandled exception of type 'System.NullReferenceException' occurred in
MemberBase.exe
Additional information: Object reference not set to an instance of an
object.
This is the code:-
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim myconnection As Odbc.OdbcConnection
myconnection = New Odbc.OdbcConnection("DSN=memberbase")
Dim mysql As String
Dim myda As Odbc.OdbcDataAdapter
mysql = "UPDATE tblMembers SET LastName = 'Johnson' WHERE MemberID
= 6666"
Dim dsOutCmdBuild As New Odbc.OdbcCommandBuilder(myda)
dsOutCmdBuild.QuotePrefix = "["
dsOutCmdBuild.QuoteSuffix = "]"
Dim UpdateCommand = New Odbc.OdbcCommand(mysql, myconnection)
myda.UpdateCommand = UpdateCommand
myconnection.Open()
Dim custDS As DataSet = New DataSet
myda.Fill(custDS)
myda.Update(custDS)
myconnection.Close()
End Sub
The LastName and MemberID fields exist and I have a MemberID of 6666.
Any ideas as to what is wrong?
Thanks
Peter.