Hey i just need a little help here,may tables are in a relationship so i want to update both tables so am using datarelation to do that but a get an exception(Column argument cannot be null).please help

OleDbDataAdapter adapter = new OleDbDataAdapter(OledbSql,conn);
                //adapter.SelectCommand = new OleDbCommand(OledbSql, conn);
                OleDbCommandBuilder oleBuilder = new OleDbCommandBuilder(adapter);
                adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                

                //dataAdapter for both objects
                OleDbDataAdapter EmployeeAdapter = new OleDbDataAdapter("SELECT * FROM Employee", conn);
                OleDbDataAdapter BankingAdapter = new OleDbDataAdapter("SELECT * FROM BankingDetails", conn);
                EmployeeAdapter.Fill(ds, "Employee");
                BankingAdapter.Fill(ds, "BankingDetails");

                //datarelation between Employee and Banking Details
                DataRelation HRsystemTableRelation = ds.Relations.Add("EmpBank", ds.Tables["Employee"].Columns["Account_Number"],
                    ds.Tables["BankingDetails"].Columns["Account_Number"]);

>i want to update both tables

Create two dataAdapters, and two commandBuilder objects. (Have you turn on/off Cascade update/delete Ms-Access feature?)

OleDbDataAdapter EmployeeAdapter = new OleDbDataAdapter("SELECT * FROM Employee", conn);

OleDbCommandBuilder cb1=new OleDbCommandBuilder(EmployeeAdapter);


OleDbDataAdapter BankingAdapter = new OleDbDataAdapter("SELECT * FROM BankingDetails", conn);

OleDbCommandBuilder cb2=new OleDbCommandBuilder (BankingAdapter);

EmployeeAdapter.Fill(ds, "Employee");
BankingAdapter.Fill(ds, "BankingDetails");

.....
.....
EmployeeAdapter.Update(ds, "Employee");
BankingAdapter.Update(ds, "BankingDetails");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.