473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Updating 2 Tables at once

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

Aug 20 '06 #1
10 1094
MRW
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!
Aug 20 '06 #2
"MRW" <mw*****@yahoo.comwrote in message
news:11**********************@75g2000cwc.googlegro 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.
Aug 20 '06 #3
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!
Aug 20 '06 #4
MRW
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!
Aug 20 '06 #5
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!
Aug 20 '06 #6
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!
Aug 20 '06 #7
MRW
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!
Aug 20 '06 #8
"MRW" <mw*****@yahoo.comwrote in message
news:11**********************@m79g2000cwm.googlegr 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...
Aug 20 '06 #9
MRW
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" <mw*****@yahoo.comwrote in message
news:11**********************@m79g2000cwm.googlegr 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...
Aug 21 '06 #10
JT
To Mark & Sarat:

We all appreciate your help. And I try to help when I can. Isn't that
why this group is here? If we are just going to tell people to go look
on Google, why does this group exist? I'm sure you're both very
helpful and generous in most cases. If you were a guru sitting on a
mountaintop and someone climbed up to ask a question, wouldn't you
think they were an idiot if they climbed back down and then had to
climb back up to ask a follow-up question instead of asking while they
had your attention?

Now blithering idiots should go study before peppering you with inane
questions, but that's a different situation (IMHO).

We all have bad days...

BTW, I benefitted from your answers, too.

Thanks.

MRW wrote:
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" <mw*****@yahoo.comwrote in message
news:11**********************@m79g2000cwm.googlegr 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...
Aug 21 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christa Waggett | last post by:
Hi, I'm not a programmer but would appreciate some help with the following. I've been looking at various sites but cannot find the information I require. I have a table of strata plans and if we...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
1
by: rdemyan via AccessMonster.com | last post by:
My App has 10 or so tables that we provide that contains proprietary data. This data will need to be updated once or twice a year. I would like some comments, suggestions on my proposed strategy...
5
by: JimmyKoolPantz | last post by:
Situation: I am writing a program that opens up a data file (file ext .dbf), imports the information into a dataset. The program also, searches through the dataset for key words ("company...
3
by: John Morgan | last post by:
I have my first small SQl Server 2005 database developed on my local server and I have also its equivalent as an online database. I wish to update the local database (using and asp.net interface)...
1
by: thandiwe | last post by:
may somebody help me, i am working on an access database and my tables have related fields. i want these fields to update at once after updating one of them..the fields have formulas, so i would...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.