You're right. The problem is that the ClientID is not being passed back to
the dataset, however, I'm not sure how to set up the dataAdapter to do this
or if there is another way to do this.
Currently the code looks like this:
The insertCommand for OleDbDataAdapter for ClientName:
I'm not passing back the ClientID but not sure if that's possible in the
same insert command.
// Create the InsertCommand.
cmd = new OleDbCommand("INSERT INTO ClientName (FirstName, LastName,
FullName) " +
"VALUES (@ClientID, @FirstName, @LastName, @FullName)", myConn);
cmd.Parameters.Add("@FirstName", OleDbType.Char, 50, "FirstName");
cmd.Parameters.Add("@LastName", OleDbType.VarChar, 50, "LastName");
cmd.Parameters.Add("@FullName", OleDbType.VarChar, 50, "FullName");
ClientName_OleDbDataAdapter.InsertCommand = cmd;
The code to insert the actual values for ClientName is this:
OleDbDataAdapter dbadapter = new OleDbDataAdapter();
// Update ClientName Table
dbadapter = Return_ClientName_OleDbDataAdapter();
DataRow myNewRow = AddClientDataSet.Tables["ClientName"].NewRow();
myNewRow["FirstName"] = this.tbFirstName.Text;
myNewRow["LastName"] = this.tbLastName.Text;
myNewRow["FullName"] =
this.tbLastName.Text.TrimEnd(null)+","+this.tbFirstName.Text.TrimEnd(null);
AddClientDataSet.Tables["ClientName"].Rows.Add(myNewRow);
dbadapter.Update(AddClientDataSet, "ClientName");
John
[quoted text, click to view] "NuTcAsE" <rao.ritesh@gmail.com> wrote in message
news:1107194646.556096.312490@c13g2000cwb.googlegroups.com...
> Can you please post the code where your updating the ClientName table.
> There might be an error where the auto generated client id from the
> database is not being updated into the ClientName table. Check if an
> Output parameter is added to the insert command, and the SoureColumn of
> that parameter is set to ClientId. This will make sure that the
> autogenerated ClientId is reflected back to the ClientId column in your
> ClientName table.
>