|
-
Feb 12th, 2004, 08:11 AM
#1
Thread Starter
Hyperactive Member
can not update database
I have some textboxes bound to a table's different field. I can load data to the textboxes, and after I make some changes, I click a button to update my database. No error, no update to the database. But another datagrid tells me that "Update requires the updateCOmmand to have a connection object. The connection property of the updateCOmmand has not be initialized".
I post my code here, can somebody help?
Public conString As String = "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=myDB"
Public conn As OdbcConnection = New OdbcConnection(conString)
Public daStudents As OdbcDataAdapter = New OdbcDataAdapter("Select * From tblStudent", conn)
Public dsStudents As DataSet = New DataSet()
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
Try
daStudents.UpdateCommand = New OdbcCommand("Update tblStudent set studentID = 'S999' Where Studentid = 'S002'")
daStudents.Update(dsStudents, "tblStudent")
Catch MyOdbcException As OdbcException
Console.WriteLine(MyOdbcException.ToString)
Catch MyException As Exception
Console.WriteLine(MyException.ToString)
End Try
end sub
Last edited by Palmtree; Feb 12th, 2004 at 09:36 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|