i use connector
i have two tables with the following contents:
tbl_user_info
tbl_account
- user_id(Primary Key)
- fname
- lname
NOW, i want this two tables to be displayed in the datagridview
- account_id(Primary Key)
- user_id(Foreign Key)
- username
- password
so i used this codes:
Expand|Select|Wrap|Line Numbers
- 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:
Expand|Select|Wrap|Line Numbers
- 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