December 9, 2008 at 3:58 am
Hi
I am trying to create a SP which will allow me insert into 2 table from an ASP.NET web page.
There are no fancy requirements just the insert of the data being inputted into the web page.
Thank You
Mick
December 9, 2008 at 4:24 am
Not enough information.
What does the ASP page need to pass to the server?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 9, 2008 at 4:31 am
Sorry
I need the following 2 inserts to happen once i select a submit button on the ASP page:
INSERT INTO [MobilePhones].[dbo].[tblPerson]
([StaffNumber]
,[AccountCode]
,[IMEINumber]
,[SIMNumber])
VALUES
(
,
,
, )
INSERT INTO [MobilePhones].[dbo].[tblPersonRequestDetails]
([StaffNumber]
,[BusinessReason]
,[Requirements])
VALUES
(
,
, )
As you can see Staff Number is the key for the 2 tables.
Thank You
Mick
December 9, 2008 at 4:41 am
Hi
Your requirement seems pretty simple. Dont think you need the actual code...Just lookup the BOL on how to create procedures.
Make sure you are doing the inserts inside a transaction.
You will need input parameters that will be inserted into the tables.
Put error handling code to handle any errors while doing the inserts.
"Keep Trying"
December 10, 2008 at 9:40 am
I'm wondering if there isn't something more at play here. The SQL necessary to do an insert into two tables doesn't change just because it has to appear in a stored procedure. I'm just wondering if there's a relationship between the two tables that requires that each table's PK reference the other's PK, which would make ANY insert into either table impossible at any time after that constraint was put in place. Of course, since the original poster hasn't provided the scripted CREATE statements for both tables, there's no way to know.
Then again, for all I know, perhaps SQL prevents you from hanging yourself that way?
Steve
(aka smunson)
:):):)
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
December 10, 2008 at 11:23 pm
Well i assume that the op will insert data into the first table (which ever it is ) and then into the other table....in the normal way.
"Keep Trying"
December 11, 2008 at 2:49 am
Thanks for everyones reply to this.
I got it working and it was a simple insert into the 2 tables which done it for me!
Thanks Again
Mick
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply