Mark,
These links should get you going on transactions for .net and sql server.
Shoot me an email if you have issues.  

http://www.knowdotnet.com/articles/transactions.html

http://authors.aspalliance.com/hrmalik/articles/2002/200217/20021701.aspx

Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 |
[EMAIL PROTECTED]


-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] Behalf Of Mark E
Sent: Friday, July 01, 2005 8:33 AM
To: [email protected]
Subject: Re: [AspNetAnyQuestionIsOk] Hi and some C# ASP.net help


Matt,
 
If you're using a stored procedure for this process, you can use the
following to grab the ID of a record that was just inserted from step 1 in
order to use it in step 2:
 
Declare @New_ID int
 
-- do your personnel insert here...
insert into personnel (....)
values (....)
 
-- Now get the id for the new personnel record.
select @New_ID = @@identity
 
Now that you have your new ID, use it when inserting the second record in
the personnelDetails table:
 
-- do your personnel details insert here...
insert into personneldetails (PersonnelID, ....)
values (@New_ID, ....)
 
If you're not using a stored procedure, you could run a select statement to
get the ID back after your insert from step 1, although there may be a
chance that 2 records in the personnel table could have the same values. 

 
Mark

Matthew Macdonald-Wallace <[EMAIL PROTECTED]> wrote:
Hi all,

I thought I'd introduce myself before I start begging for help!

I'm just about to recommence a career in IT and am currently training
to get the MCP.net/MCAD/MCSA/MSDBA qualifications.  I have a linux
background and am very keen to see how well I can integrate MS
products and Open-source alternatives through the .net framework.  My
knowledge of C# and the ASP platform is no-where near as good as my
skills in other languages, but there we go, that's life! :)

My question is as follows:

I'm currently trying to insert data into a number of tables in a MSSQL
Server database.  My current logic (and this is not yet in code!) goes
something like this:

1. Insert the user's Firstname, lastname, emailaddress and password
into the "personnel" table.

2. Extract the new users ID from the "personnel" table and use it to
insert their postaladdress, phonenumber, fax number into the
"personnelDetails" table.

3. using the postcode from the "personnelDetails" table, suggest a
branchId (through a "SELECT * FROM branches WHERE branchPostCode LIKE
%postcode%" kind of thing...)

4. add them to the selected branch.


If anyone can help me get around this, that would be great.  The main
issue is with step 2 and extracting the person's ID.

Thanks in Advance,

Matt






---------------------------------
YAHOO! GROUPS LINKS 


    Visit your group "AspNetAnyQuestionIsOk" on the web.
  
    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
  
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


---------------------------------




[Non-text portions of this message have been removed]



 
Yahoo! Groups Links



 



*************************************************************************
PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited.  If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to