I know I must be doing something really dumb but I can't work out the problem. The code is below. The Update line (4 from the bottom) causes a MySQL (v4 I think) failure: "Column 'MbrMemberId' cannot be null ". The field does appear to be present in the dataset but somehow I guess I'm failing to substitute the parameters. I've tried question marks instead of '@' but no joy. Any help would be appreciated.
Code:
Dim oConnection As OdbcConnection = New OdbcConnection(DbConnect)
Dim sSQL As String = "SELECT * FROM Mbr"
Dim DadMbr As OdbcDataAdapter = New OdbcDataAdapter(sSQL, oConnection)
Dim DstMbr As DataSet = New DataSet(), RowNew As DataRow
DadMbr.MissingSchemaAction = MissingSchemaAction.AddWithKey 'this will convince lookup code that table has a primary key
DadMbr.Fill(DstMbr, "Mbr")
RowNew = DstMbr.Tables(0).NewRow()
With RowNew
.Item("MbrMemberId") = TxtLoginRG.Text
.Item("MbrPassword") = TxtPasswordRG.Text
.Item("MbrName") = TxtName.Text
.Item("MbrEmail") = TxtEmail.Text
.Item("MbrPhone") = TxtPhone.Text
Response.Write("MEMBER ID: " & .Item("MbrMemberId"))
End With
DstMbr.Tables(0).Rows.Add(RowNew)
Response.Write("<br/>UPDATE SUCCESSFUL")
DadMbr.InsertCommand = New OdbcCommand( _
"INSERT INTO Mbr(MbrMemberId, MbrPassword, MbrName, MbrEmail, MbrPhone) " & _
"VALUES (@MbrMemberId, @MbrPassword, @MbrName, @MbrEmail, @MbrPhone)", oConnection)
' "INSERT INTO Mbr (MbrMemberId, MbrPassword) VALUES (@MemberId, @Password)", oConnection)
DadMbr.InsertCommand.Parameters.Add("@MbrMemberId", OdbcType.VarChar, 10, "MbrMemberId")
DadMbr.InsertCommand.Parameters.Add("@MbrPassword", OdbcType.VarChar, 30, "MbrPassword")
DadMbr.InsertCommand.Parameters.Add("@MbrName", OdbcType.VarChar, 30, "MbrName")
DadMbr.InsertCommand.Parameters.Add("@MbrEmail", OdbcType.VarChar, 30, "MbrEmail")
DadMbr.InsertCommand.Parameters.Add("@MbrPhone", OdbcType.VarChar, 30, "MbrPhone")
DadMbr.Update(DstMbr, "Mbr")
Response.Write("<br/>DATABASE UPDATE SUCCESSFUL")
DgdMbr.DataSource = DstMbr
DgdMbr.DataBind()