database: MySQL
i use connector
i have two tables with the following contents:
tbl_user_info
tbl_account
NOW, i want this two tables to be displayed in the datagridview
so i used this codes:
I just allow only fname or lname to get modified because i want to modify the table tbl_user_info
And here's my code in updating to database
WHEN BUTTON "SAVE CHANGES" is clicked:
But nothing's happen when i click the button.
Please Help me figure out my codes and suggest if there's any other way to save changes from datagridview to database.
regards,
ARJEL
i use connector
i have two tables with the following contents:
tbl_user_info
- user_id(Primary Key)
- fname
- lname
tbl_account
- account_id(Prim ary Key)
- user_id(Foreign Key)
- username
- password
NOW, i want this two tables to be displayed in the datagridview
so i used this codes:
Code:
sql = "SELECT * FROM tbl_user_info"
sql1 = "SELECT username,fname,lname FROM tbl_user_info,tbl_account WHERE tbl_user_user_info.user_id=tbl_account.user_id"
'CODES CONNECTING TO DATABASE
conn.Open()
sda = New MySqlDataAdapter(sql, conn)
sda1 = New MySqlDataAdapter(sql1, conn)
cmbuilder = New MySqlCommandBuilder(sda)
cmbuilder = New MySqlCommandBuilder(sda1)
sda.Fill(ds, "tbl_user_info")
sda1.Fill(ds, "tbl_account")
bsource.DataSource = ds
bsource.DataMember = "tbl_account"
DataGridView1.DataSource = bsource
conn.Close()
And here's my code in updating to database
WHEN BUTTON "SAVE CHANGES" is clicked:
Code:
sda1.Update(ds, "tbl_user_info")
Please Help me figure out my codes and suggest if there's any other way to save changes from datagridview to database.
regards,
ARJEL
Comment