Steve Schaaf

Results 1 to 2 of 2

Thread: Steve Schaaf

  1. #1
    Steve Schaaf Guest

    Default Steve Schaaf

    How can I access Two Different Tables in after setting up a DSN ?<BR><BR>Example<BR><BR>DSN=Database Table=User<BR>Response.Write "Field1 out of User"<BR>Response.Write "Field1 out of Customer taht relates to Field1 of User "<BR><BR>Please Help !<BR><BR>Can I define two tables in Connection Object ?<BR><BR><BR><BR>

  2. #2
    David Highlander Guest

    Default Yes you can do it like this:

    Ok I am assuming your two tables are called "User" and "Customer" and that they are joined together by "Field1" - (You can replace Field1 with the name of your field that joins the 2 tables)<BR><BR>Ok I am going to show you an example then I will explain what it means:<BR><BR>&#060;%<BR>Dim Sqldetails<BR>Sqldetails = "SELECT U.Field1, C.Field1, " & _<BR> "FROM User U, Customer C " & _<BR> "WHERE U.Field1 = " & NEED TO ENTER & " " & _<BR> "AND U.Field1 = C.Field1"<BR><BR>Then you open your database connection like you usually do and then assign variables to your recordsets<BR>%&#062;<BR><BR>Now what this means is:<BR><BR>"FROM User U, Customer C " & _ - This line assigns aliases to your table fields - other wise instead of typing U.field1 - you would have typed user.field1 and that can get cumbersome if you have several fields you are trying to bring back.<BR><BR>"AND U.Field1 = C.Field1" - This line of code confirms that the two databases are join by this field and will make sure that the right data is returned.<BR><BR>"WHERE U.Field1 = " & NEED TO ENTER & " " & _ - Ok you can substitute C.Field1 in place of U.Field1 depending on what variable you are looking for. There is no way I can know. and where I have "NEED TO ENTER" you will probably have Request.Form("whatever") there or something like that.<BR><BR>I hope this at least helps get you started.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts