Can't insert records from vb.net to mysql, why?

sasquatch

New member
Joined
Oct 5, 2006
Messages
2
Programming Experience
Beginner
here is the code I am using. I'm not getting any errors now but the new record is not getting added to the database either. You can see there is a msgbox that displays the first record of the database. This works so the connection is working fine. but I cannot seem to update or add to the database.

Dim Con As New OleDb.OleDbConnection("Provider=MySQLProv;Location=mytestdomain.com;Data Source=mydbname;User Id=xyz;Password=mypassword;")
Dim ds As New DataSet()
Dim da As OleDb.OleDbDataAdapter
Dim sql As String

sql = "select * from profile"

da = New OleDb.OleDbDataAdapter(sql, Con)
da.Fill(ds, "profile")

MsgBox("first row=" & ds.Tables("profile").Rows(0).Item(0))
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow

dsNewRow = ds.Tables("profile").NewRow()
dsNewRow.Item("email") = "test@yahoo.com"
'dsNewRow.Item(1) = "test2@yahoo.com"
dsNewRow.Item("pwd") = "testpassword"
ds.Tables("profile").Rows.Add(dsNewRow)
ds.AcceptChanges()
da.Update(ds, "profile")

MsgBox("check table for updates")

Con.Close()
 
Back
Top