ev66
Member
- Joined
- Apr 2, 2007
- Messages
- 9
- Programming Experience
- Beginner
Hi
I want to update my database table by saving the whole datagrid to it. Ive
managed to get data from dB table and display it in datagrid so i can edit it, but
cant save it. It does not show any errors but the new data is not saved.
I've read load of articles and google searches but still cant get it to work.
The only thing the articles do not elaborate on is the SELECT statement, is mine
ok ?
Please help, I've been trying to get this to work for 2 days now.
Thanks
Dim conn As New MySqlConnection
Dim SQL As String
SQL = "SELECT * FROM mytable"
conn.ConnectionString = "server=" & text1.Text & ";" _
& "user id=" & text2.Text & ";" _
& "password=" & text3.Text & ";" _
& "database=mymedia"
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
Dim adapter As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM mytable", conn)
Dim myset As New DataSet
' Fill the DataSet.
adapter.Fill(myset)
'update
adapter.Update(myset)
MsgBox("Update OK")
conn.Close()
I want to update my database table by saving the whole datagrid to it. Ive
managed to get data from dB table and display it in datagrid so i can edit it, but
cant save it. It does not show any errors but the new data is not saved.
I've read load of articles and google searches but still cant get it to work.
The only thing the articles do not elaborate on is the SELECT statement, is mine
ok ?
Please help, I've been trying to get this to work for 2 days now.
Thanks
Dim conn As New MySqlConnection
Dim SQL As String
SQL = "SELECT * FROM mytable"
conn.ConnectionString = "server=" & text1.Text & ";" _
& "user id=" & text2.Text & ";" _
& "password=" & text3.Text & ";" _
& "database=mymedia"
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
Dim adapter As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM mytable", conn)
Dim myset As New DataSet
' Fill the DataSet.
adapter.Fill(myset)
'update
adapter.Update(myset)
MsgBox("Update OK")
conn.Close()