Wow, what a fast response! :)

Thanks Mark and Travis, that's exactly the kind of thing I'm looking
for.  As I said, I'm just starting out with ASP.net and C#, and the idea
of transactions are fairly new to me (been working with PHP/MySQL up
until now!).

it makes a lot of sense to do it this way, so I'll give it a go and
report back!

Thanks again,

Matt

On Fri, 1 Jul 2005 05:32:38 -0700 (PDT)
Mark E <[EMAIL PROTECTED]> wrote:

> 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
> 
> 
> 
>  
> 
> 


 
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