Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Updating 2 Tables at once

Reply
Thread Tools

Updating 2 Tables at once

 
 
MRW
Guest
Posts: n/a
 
      08-20-2006
Quick question for anybody who can help:

I have two tables:

tblUsers
--------
UserID
Name

tblPhones
---------
PhoneID
UserID
PhoneNumber

If I'm collecting the name and the phone numbers (can be multiple
numbers) in one form, what's the best way of placing it in the
database? The question revolves around the UserID and making sure the
tblPhones.UserID = tblUsers.UserID

Thanks for any help!

 
Reply With Quote
 
 
 
 
MRW
Guest
Posts: n/a
 
      08-20-2006
Oh yes... tblUsers.UserID is automatically incremented in the
database...

MRW wrote:
> Quick question for anybody who can help:
>
> I have two tables:
>
> tblUsers
> --------
> UserID
> Name
>
> tblPhones
> ---------
> PhoneID
> UserID
> PhoneNumber
>
> If I'm collecting the name and the phone numbers (can be multiple
> numbers) in one form, what's the best way of placing it in the
> database? The question revolves around the UserID and making sure the
> tblPhones.UserID = tblUsers.UserID
>
> Thanks for any help!


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      08-20-2006
"MRW" <> wrote in message
news: ups.com...

> Quick question for anybody who can help:
>
> I have two tables:
>
> tblUsers
> --------
> UserID
> Name
>
> tblPhones
> ---------
> PhoneID
> UserID
> PhoneNumber
>
> If I'm collecting the name and the phone numbers (can be multiple
> numbers) in one form, what's the best way of placing it in the
> database? The question revolves around the UserID and making sure the
> tblPhones.UserID = tblUsers.UserID
>
> Thanks for any help!


Is the UserID already known, or are you adding one record to tblUsers and
one or more to tblPhones? If the former, is tblUsers.UserID an identity
field? If so, you can retrieve the identity by SELECT @@IDENTIY or SELECT
SCOPE_IDENTITY. Then you can use that to pump the records into tblPhones.


 
Reply With Quote
 
Sarat Pediredla
Guest
Posts: n/a
 
      08-20-2006
Based on that fact that you mention that the UserID is an auto
incremented field, I am assuming this is an IDENTITY and the SELECT
@@IDENTITY in your SQL should do it for you.

MRW wrote:
> Quick question for anybody who can help:
>
> I have two tables:
>
> tblUsers
> --------
> UserID
> Name
>
> tblPhones
> ---------
> PhoneID
> UserID
> PhoneNumber
>
> If I'm collecting the name and the phone numbers (can be multiple
> numbers) in one form, what's the best way of placing it in the
> database? The question revolves around the UserID and making sure the
> tblPhones.UserID = tblUsers.UserID
>
> Thanks for any help!


 
Reply With Quote
 
MRW
Guest
Posts: n/a
 
      08-20-2006
Thanks for the feedback!

I'll be honest. I'm not familiar with the @@IDENTITY. Can you give a
quick example on how it is used (VB)?

Thank you for the help!

Sarat Pediredla wrote:
> Based on that fact that you mention that the UserID is an auto
> incremented field, I am assuming this is an IDENTITY and the SELECT
> @@IDENTITY in your SQL should do it for you.
>
> MRW wrote:
> > Quick question for anybody who can help:
> >
> > I have two tables:
> >
> > tblUsers
> > --------
> > UserID
> > Name
> >
> > tblPhones
> > ---------
> > PhoneID
> > UserID
> > PhoneNumber
> >
> > If I'm collecting the name and the phone numbers (can be multiple
> > numbers) in one form, what's the best way of placing it in the
> > database? The question revolves around the UserID and making sure the
> > tblPhones.UserID = tblUsers.UserID
> >
> > Thanks for any help!


 
Reply With Quote
 
Sarat Pediredla
Guest
Posts: n/a
 
      08-20-2006
I feel generous today, so here you go. 2 mins on Google could have got
you that.

http://support.microsoft.com/default...en-us%3B815629

MRW wrote:
> Thanks for the feedback!
>
> I'll be honest. I'm not familiar with the @@IDENTITY. Can you give a
> quick example on how it is used (VB)?
>
> Thank you for the help!
>
> Sarat Pediredla wrote:
> > Based on that fact that you mention that the UserID is an auto
> > incremented field, I am assuming this is an IDENTITY and the SELECT
> > @@IDENTITY in your SQL should do it for you.
> >
> > MRW wrote:
> > > Quick question for anybody who can help:
> > >
> > > I have two tables:
> > >
> > > tblUsers
> > > --------
> > > UserID
> > > Name
> > >
> > > tblPhones
> > > ---------
> > > PhoneID
> > > UserID
> > > PhoneNumber
> > >
> > > If I'm collecting the name and the phone numbers (can be multiple
> > > numbers) in one form, what's the best way of placing it in the
> > > database? The question revolves around the UserID and making sure the
> > > tblPhones.UserID = tblUsers.UserID
> > >
> > > Thanks for any help!


 
Reply With Quote
 
Sarat Pediredla
Guest
Posts: n/a
 
      08-20-2006
Ok, looks like I pasted a dummy link there. Here is another go.

http://www.informit.com/articles/art...&seqNum=4&rl=1

MRW wrote:
> Thanks for the feedback!
>
> I'll be honest. I'm not familiar with the @@IDENTITY. Can you give a
> quick example on how it is used (VB)?
>
> Thank you for the help!
>
> Sarat Pediredla wrote:
> > Based on that fact that you mention that the UserID is an auto
> > incremented field, I am assuming this is an IDENTITY and the SELECT
> > @@IDENTITY in your SQL should do it for you.
> >
> > MRW wrote:
> > > Quick question for anybody who can help:
> > >
> > > I have two tables:
> > >
> > > tblUsers
> > > --------
> > > UserID
> > > Name
> > >
> > > tblPhones
> > > ---------
> > > PhoneID
> > > UserID
> > > PhoneNumber
> > >
> > > If I'm collecting the name and the phone numbers (can be multiple
> > > numbers) in one form, what's the best way of placing it in the
> > > database? The question revolves around the UserID and making sure the
> > > tblPhones.UserID = tblUsers.UserID
> > >
> > > Thanks for any help!


 
Reply With Quote
 
MRW
Guest
Posts: n/a
 
      08-20-2006
Great! Thanks a lot!


Sarat Pediredla wrote:
> Ok, looks like I pasted a dummy link there. Here is another go.
>
> http://www.informit.com/articles/art...&seqNum=4&rl=1
>
> MRW wrote:
> > Thanks for the feedback!
> >
> > I'll be honest. I'm not familiar with the @@IDENTITY. Can you give a
> > quick example on how it is used (VB)?
> >
> > Thank you for the help!
> >
> > Sarat Pediredla wrote:
> > > Based on that fact that you mention that the UserID is an auto
> > > incremented field, I am assuming this is an IDENTITY and the SELECT
> > > @@IDENTITY in your SQL should do it for you.
> > >
> > > MRW wrote:
> > > > Quick question for anybody who can help:
> > > >
> > > > I have two tables:
> > > >
> > > > tblUsers
> > > > --------
> > > > UserID
> > > > Name
> > > >
> > > > tblPhones
> > > > ---------
> > > > PhoneID
> > > > UserID
> > > > PhoneNumber
> > > >
> > > > If I'm collecting the name and the phone numbers (can be multiple
> > > > numbers) in one form, what's the best way of placing it in the
> > > > database? The question revolves around the UserID and making sure the
> > > > tblPhones.UserID = tblUsers.UserID
> > > >
> > > > Thanks for any help!


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      08-20-2006
"MRW" <> wrote in message
news: oups.com...

> Great! Thanks a lot!


Sarat's comment about Google is very relevant, though... you really could
have found this out for yourself in a matter of seconds...


 
Reply With Quote
 
MRW
Guest
Posts: n/a
 
      08-21-2006
I've been on Google searching for things for hours. I did not find
anything that would have led me to @@IDENTITY. So when he told me, I
simply asked if he had a quick example on how to use it while I've got
him.


Mark Rae wrote:
> "MRW" <> wrote in message
> news: oups.com...
>
> > Great! Thanks a lot!

>
> Sarat's comment about Google is very relevant, though... you really could
> have found this out for yourself in a matter of seconds...


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
updating multiple tables evandela@bigpond.net.au ASP .Net 1 03-21-2006 02:55 PM
Regex to match say char 't' exactly once in a string and no more than once Gancy Perl Misc 4 02-03-2005 02:05 PM
Updating multiple Tables =?Utf-8?B?SnVzdGlu?= ASP .Net 1 11-22-2004 01:16 PM
Updating Related Tables from Dataset Shiv ASP .Net 0 10-17-2003 01:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57