Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2006

Tip: Looking for answers? Try searching our database.

SqlDataSource - Insert to 2 tables problem.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ssims - 01 Dec 2006 14:46 GMT
I'm working with ASP.Net on IIS 5.1 and MSSQL 2000 and have a rather
frustrating problem.  I'm trying to insert a record to a table, get the
identity value, and insert two additional records to a second table.
My insert command looks like this:

INSERT INTO TableA VALUES(PK_NameID, CQ1, CQ2, CQ3, CQ4);
DECLARE @ID int;
SET @ID = SCOPE_IDENTITY();
INSERT INTO TableB VALUES(@ID, IQ1, IQ2, IQ3, IQ4);
INSERT INTO TableB VALUES(@ID, IQ1, IQ2, IQ3, IQ4);

The insert command is all mashed together in the InsertCommand
parameter of a SqlDataSource.  When I run the query by hand in sqlcmd,
everything works beautifully, but when I try to run it on the page,
only the first insert command is processed.  I can't find any
information in any of the logs or anywhere on Google to suggest what is
going wrong.  Any help is greatly appreciated.

Thanks,

-Sean
bpd - 01 Dec 2006 15:17 GMT
Try putting the command in a stored procedure and use the stored
procedure in your SQLDataSource.

> I'm working with ASP.Net on IIS 5.1 and MSSQL 2000 and have a rather
> frustrating problem.  I'm trying to insert a record to a table, get the
[quoted text clipped - 17 lines]
>
> -Sean

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.