J
J
I previously used the following which works fine:
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(daAccount);
daAccount.Update(dsAccount, "Account");
But now I also want to retrieve the resulting identity column value from an
INSERT. So I tried the following:
daAccount.InsertCommand.CommandText = "INSERT into account (userid,
organization, groupdesc, stage, sizepotential) VALUES (@userid,
@organization, @groupdesc, @stage, @sizepotential); Select accountid =
SCOPE_IDENTITY()";
daAccount.Update(dsAccount, "Account");
But the InsertCommand returns a "NullReferenceException...Object reference
not set to an instance of an object". The dataAdapter is not null as it
worked in the first case (also "? daAccount == null" returns false). It's
not clear what the exception is telling me. Secondly, how does the
dataAdapter.Update know to plug in the correct dataSet columns into the
corresponding @valuename's?
Many thanks
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(daAccount);
daAccount.Update(dsAccount, "Account");
But now I also want to retrieve the resulting identity column value from an
INSERT. So I tried the following:
daAccount.InsertCommand.CommandText = "INSERT into account (userid,
organization, groupdesc, stage, sizepotential) VALUES (@userid,
@organization, @groupdesc, @stage, @sizepotential); Select accountid =
SCOPE_IDENTITY()";
daAccount.Update(dsAccount, "Account");
But the InsertCommand returns a "NullReferenceException...Object reference
not set to an instance of an object". The dataAdapter is not null as it
worked in the first case (also "? daAccount == null" returns false). It's
not clear what the exception is telling me. Secondly, how does the
dataAdapter.Update know to plug in the correct dataSet columns into the
corresponding @valuename's?
Many thanks