PC Review


Reply
Thread Tools Rate Thread

DataAdapter InsertCommand problems

 
 
J
Guest
Posts: n/a
 
      28th Feb 2008
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dataAdapter InsertCommand problems J Microsoft C# .NET 2 5th Mar 2008 02:05 PM
difference between dataAdapter.InsertCommand/dataAdapter.SelectCom =?Utf-8?B?UmljaA==?= Microsoft VB .NET 3 10th Nov 2006 03:34 PM
UpdateCommand and InsertCommand for the same DataAdapter? Rico Microsoft ADO .NET 4 23rd Mar 2006 12:01 AM
Re: using dataadapter.update changes the insertcommand.commandtext W.G. Ryan MVP Microsoft ADO .NET 2 1st Sep 2005 05:43 PM
Creating SQL Statement from Dataadapter Insertcommand Kamal Vaghjiani Microsoft ADO .NET 7 6th Apr 2004 04:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:29 AM.