5 Replies - 939 Views - Last Post: 10 November 2008 - 11:37 AM Rate Topic: -----

#1 4x4pirate  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 18-October 06

Two tables - one table needs to have a field from the other table

Posted 10 November 2008 - 06:20 AM

Ok,

I posted on the VB.net side of the house a few Database questions that haven't been answerred, so I figured I would try on this side.

Is there a way to create a Procedure that will copy a field from one table to the other table


See I am stuck, and my project doesn't need to use a database, but I chose to add one to it.


I have one database called: CustomerDatabase

In that database I have a bunch of tables, but the two I am working with are CustomersTBL and ReservationsTBL.

A customer can be added to a table by themselves, but in order for a reservation to be made, they have to have a customerID. I need to get the CustomerID from the CustomerTBL to the CustomerID to the ReservationTBL.

Bah.. been so long since I have done database work, but adding VB makes it even rougher..

Thanks in advance!!
~Robb

Is This A Good Question/Topic? 0
  • +

Replies To: Two tables - one table needs to have a field from the other table

#2 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

Re: Two tables - one table needs to have a field from the other table

Posted 10 November 2008 - 07:08 AM

Why not just make the customer ID a foreign key in the reservations table.



And please do not start posting your questions in other threads if they have not been answered. From the sounds of it you probably should have posted this question here first.
Was This Post Helpful? 0
  • +
  • -

#3 Hary  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 427
  • Joined: 23-September 08

Re: Two tables - one table needs to have a field from the other table

Posted 10 November 2008 - 08:08 AM

The easiest way I see this now, is when your customer registers (or logs in), to store its Id in a variable.

When this customer places a reservation, use the stored Id. If an employee need to add a reservation for a certain customer, create a Dropdown or searchlist to select the correct customer (and thus retrieve its Id)
Was This Post Helpful? 0
  • +
  • -

#4 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Two tables - one table needs to have a field from the other table

Posted 10 November 2008 - 10:09 AM

Assuming the flow of your app does NOT require someone to "log in" then before anyone tries to make a reservation confirm that they are registered customers. If not then force them to register before continuing, else retrieve their customerID. Once you have the ID you should be able to insert the value into any table.
Was This Post Helpful? 0
  • +
  • -

#5 Hary  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 427
  • Joined: 23-September 08

Re: Two tables - one table needs to have a field from the other table

Posted 10 November 2008 - 10:20 AM

"Confirm that they are a customer with" and "retrieve their Id", isn't that just "logging in", but not with a username/password? ;)
Was This Post Helpful? 0
  • +
  • -

#6 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Two tables - one table needs to have a field from the other table

Posted 10 November 2008 - 11:37 AM

I suppose that depends on what your definition of "logging in" is. If this app is used by a hostess at a restaurant and she takes customer information, she won't actually "log in" as a user rather she would be a "super" user assigning customers to tables and reservations.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1