473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Updating a second DataGridView with Access Data

I have a form with two DataGridView controls. The form has linked to it an
Access database with just two tables. The second table contains unique
"child" data having a one-to-one relationship with each row of the first
table. I am able to display the first table's data in one of the
DataGridView controls - DatgaGridView_A.

What I want to do, but don't know how, is to select a row from the
DataGridView_A and have the data associated with it from the second table
displayed in DataGridView_B. Can someone show me how this is done or give me
an example?
--
-----------
Thanks,
Steve
Apr 8 '06 #1
4 1967
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
I have a form with two DataGridView controls. The form has linked to it an
Access database with just two tables. The second table contains unique
"child" data having a one-to-one relationship with each row of the first
table. I am able to display the first table's data in one of the
DataGridView controls - DatgaGridView_A.

What I want to do, but don't know how, is to select a row from the
DataGridView_A and have the data associated with it from the second table
displayed in DataGridView_B. Can someone show me how this is done or give
me
an example?
--
-----------
Thanks,
Steve

Apr 8 '06 #2
What is "conn"?
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
I have a form with two DataGridView controls. The form has linked to it an
Access database with just two tables. The second table contains unique
"child" data having a one-to-one relationship with each row of the first
table. I am able to display the first table's data in one of the
DataGridView controls - DatgaGridView_A.

What I want to do, but don't know how, is to select a row from the
DataGridView_A and have the data associated with it from the second table
displayed in DataGridView_B. Can someone show me how this is done or give
me
an example?
--
-----------
Thanks,
Steve


Apr 10 '06 #3
conn is the connection instance
SQLConnection con = new SQLConnection(....)
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:B1**********************************@microsof t.com...
What is "conn"?
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
>I have a form with two DataGridView controls. The form has linked to it
>an
> Access database with just two tables. The second table contains unique
> "child" data having a one-to-one relationship with each row of the
> first
> table. I am able to display the first table's data in one of the
> DataGridView controls - DatgaGridView_A.
>
> What I want to do, but don't know how, is to select a row from the
> DataGridView_A and have the data associated with it from the second
> table
> displayed in DataGridView_B. Can someone show me how this is done or
> give
> me
> an example?
> --
> -----------
> Thanks,
> Steve


Apr 10 '06 #4
Thank you for the direction. My issue is now resolved.
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
conn is the connection instance
SQLConnection con = new SQLConnection(....)
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:B1**********************************@microsof t.com...
What is "conn"?
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
>I have a form with two DataGridView controls. The form has linked to it
>an
> Access database with just two tables. The second table contains unique
> "child" data having a one-to-one relationship with each row of the
> first
> table. I am able to display the first table's data in one of the
> DataGridView controls - DatgaGridView_A.
>
> What I want to do, but don't know how, is to select a row from the
> DataGridView_A and have the data associated with it from the second
> table
> displayed in DataGridView_B. Can someone show me how this is done or
> give
> me
> an example?
> --
> -----------
> Thanks,
> Steve


Apr 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that...
7
by: Greg P | last post by:
I'm new to VS2005 and want to simply update my data with the dataGridView that was generated when I draged my query from the Data Sources Pane. I think I may need to create a Data Adaptor but I'm...
3
by: Rich | last post by:
Hello, If I want to update data displayed in a datagrideview/datagridview cell, how can I determine what cell I am updating? I am looking at the click event below, for example. Can I get...
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
1
by: weird0 | last post by:
How can i update the data in my database directly through datagridview....? Can anyone tell me the appropriate links and what is the exact event in datagridview that handles it and some explanation...
2
by: snowdog17 | last post by:
Hello, I am a student and I need help with my VB task. I am currently using VB 2005 Express and I am fairly new to it, although I have programed in Delphi before....
2
by: hjin | last post by:
DataGridView takes very much time if I update a lot of data I have a DataGridView which has a DataSource (a DataTable) of 3000 rows. If I want to update one column of every rows in the DataTable,...
0
by: Shataken | last post by:
I have an application that allows the user to select a table name from a combobox. Once the table is selected it fills in a DataGridView with the info from that table. I need to let them make any...
5
by: Bill Schanks | last post by:
I have a winform app (VB 2005) that allows users to export data to excel, make updates to the excel file and import the data from that Excel file and update the database. My question is: Is it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.