Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

synch 2 tables

Status
Not open for further replies.

cmgaviao

Programmer
Oct 30, 2002
37
US
I'm new to C#, so pardon any assumptions I make...

I have 2 datatables, in a dataset. both bound to their own datagrid. The idea would be that the user scrolling through datagrid one would see the records in datagrid2 get updated with the child records from Table1.

Tables are as follows:

Table1:

TableName Synch

Table2:

TableName FieldName Synch

Table1 being a list of Tables in database and Table2 a list of Fields in the Table.

In the Beginning of the app, I use a different sqladapter for each table to fill DataSet1

In dataGrid's CurrentCellChanged Event I have added the Folowing 2 lines of Code to update what should be in the child table/dataGrid:

sqlDataAdapter2.SelectCommand.CommandText = "Select * from tblUpdataeFields Where TABLENAME = '" + dataSet1.tblUpdateTables.Rows[dataGrid1.CurrentRowIndex][0].ToString() + "'";

sqlDataAdapter2.Fill(dataSet1, "tblUpdateFields");

Of course they generate a nice error:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

Any assistance on how to handle this would be greatly appreciated. As I'm a newbie to C#, I'd prefer to do this in code as a learning exercise rather than interactively in the IDE.

TIA,

cmgaviao
 

I am having a similar problem with the error: An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
 

Try to take your sql statement and run it in query analyzer, other forums that I have looked at always pointed to an issue with how the sqldataadapter was incorrectly populated.

Have fun!!

-JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top