473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update joined table in datagridview

11 New Member
database: MySQL
i use connector

i have two tables with the following contents:

tbl_user_info
  • user_id(Primary Key)
  • fname
  • lname
tbl_account
  • account_id(Primary Key)
  • user_id(Foreign Key)
  • username
  • password
NOW, i want this two tables to be displayed in the datagridview

so i used this codes:
Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT * FROM tbl_user_info"
  2.         sql1 = "SELECT username,fname,lname FROM tbl_user_info,tbl_account WHERE tbl_user_user_info.user_id=tbl_account.user_id"
  3.         'CODES CONNECTING TO DATABASE
  4.         conn.Open()
  5.         sda = New MySqlDataAdapter(sql, conn)
  6.         sda1 = New MySqlDataAdapter(sql1, conn)
  7.         cmbuilder = New MySqlCommandBuilder(sda)
  8.         cmbuilder = New MySqlCommandBuilder(sda1)
  9.         sda.Fill(ds, "tbl_user_info")
  10.         sda1.Fill(ds, "tbl_account")
  11.  
  12.         bsource.DataSource = ds
  13.         bsource.DataMember = "tbl_account"
  14.         DataGridView1.DataSource = bsource
  15.         conn.Close()
  16.  
  17.  
  18.  
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:
Expand|Select|Wrap|Line Numbers
  1. sda1.Update(ds, "tbl_user_info")
  2.  
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
Feb 6 '09 #1
1 4534
adsaca
11 New Member
database: MySQL
i use connector

i have two tables with the following contents:

tbl_user_info
  • user_id(Primary Key)
  • fname
  • lname
tbl_account
  • account_id(Primary Key)
  • user_id(Foreign Key)
  • username
  • password
NOW, i want this two tables to be displayed in the datagridview

so i used this codes:
Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT * FROM tbl_user_info"
  2.         sql1 = "SELECT username,fname,lname FROM tbl_user_info,tbl_account WHERE tbl_user_user_info.user_id=tbl_account.user_id"
  3.         'CODES CONNECTING TO DATABASE
  4.         conn.Open()
  5.         sda = New MySqlDataAdapter(sql, conn)
  6.         sda1 = New MySqlDataAdapter(sql1, conn)
  7.         cmbuilder = New MySqlCommandBuilder(sda)
  8.         cmbuilder = New MySqlCommandBuilder(sda1)
  9.         sda.Fill(ds, "tbl_user_info")
  10.         sda1.Fill(ds, "tbl_account")
  11.  
  12.         bsource.DataSource = ds
  13.         bsource.DataMember = "tbl_account"
  14.         DataGridView1.DataSource = bsource
  15.         conn.Close()
  16.  
  17.  
  18.  
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:
Expand|Select|Wrap|Line Numbers
  1. sda1.Update(ds, "tbl_user_info")
  2.  
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
Feb 6 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
6
by: Greg P | last post by:
I am using VS2005 and have been learning a ton about databinding. I know that when you drag a view from the datasource window (creating a dataGridView) that an update method is not added to the...
3
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have a DataGridView that displays data from one table from database. I didn’t implement any my code, I just used wizard to do all the work with DatagridView populating. Visual Studio...
1
by: racquetballer | last post by:
I need to to an update query that involves three tables: table Dealer needs to be updated with data from table Personnel and table Title. Dealer is joined to Personnel where Dealer.Dealer_Code =...
2
by: Baddy2009 | last post by:
Hi everybody, I have a problem: I have a form and a DataGridView. I used DataAdapter to get data from the DB. My source Db have two tables, and i use the join the create e new tables in the...
5
by: Bogdan | last post by:
Hi, I have a stored procedure that uses JOINs to return columns from multiple tables. I also have another stored proc that that takes a series of params and updates multiple tables. I used the...
2
by: Oleg Subachev | last post by:
I have DataGridView which DataSource is assigned to Table<> object of DataContext connected to SQL Server database. But when the underlying SQL Server database is updated (through ODBC...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.