|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
Help with simple database relationships
Hi, I have a small problem with my Access database.
Here is my example: A table stores a userName and a Password. Another table stores up to 10 URLs. How can I make it so that each time a new user signs-up to my site, they get their own 10 spaces to save URLs? Im assuming that I have to create some sort of relationship, rather than create a new table for each users URLs to be saved. Many thanks for any help offered, Seb |
|
#2
|
|||
|
|||
|
Just store the username or userid as a foreign key in your url table. Then you can select url from urltable where userid = nnnn
If you need to preset values your signup code could insert the desired 10 blank url records at the initial login, or you could skip that and let the user's urls range from 0 to 10 or more. You may wish to define a relationship between the two tables, but it's not an absolute requirement. |
|
#3
|
|||
|
|||
|
Thanks Doug im really grateful for your help, but im afraid I have no idea how to define a foreign key in the url table in MS Access...could you please tell me how?
Many thanks! |
|
#4
|
|||
|
|||
|
give this a shot...
Code:
"CREATE TABLE tablename (
usrID whatever data type your username is,
URLs whatever data type URLSs are,
etc...........
PRIMARY KEY (usrID),
FOREIGN KEY (usrID) REFERENCES otherTableName.(usrID)
)
|
|
#5
|
|||
|
|||
|
of course if your table is loaded with lots of info and you can't recreate just add that extra line in for a contraint, I would assume access can do that but I've never touched an access DB in my life and probably shouldn't be giving advice on it but that's the SQL standard way of doing it and I assume you can do that in access as well, if anyone else can verify?
|
|
#6
|
|||
|
|||
|
thanks again for all your help, the last thing i need to know is this, look at the follwing line of code:
SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID = 1" At the end is uderID which is set to 1. How can i replace this number 1 with a string which holds a different number? thanks again! |
|
#7
|
|||
|
|||
|
it depends:
vbscript: SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID = " & string javascript: SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID = " + string |
|
#8
|
|||
|
|||
|
Hi thanks for the reply, this is what I entered:
SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID =" & sessionID bear in mind the sessionID variable holds a number (from 1 up to any number). When I try the page with your example code I get this message: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'userID ='. /faves.asp, line 23 |
|
#9
|
|||
|
|||
|
Sorry false alarm you ARE correct it DOES work! My browser had dropped the session ID for some unknown reason!
Thanks for your help! |
|
#10
|
|||
|
|||
|
Hmm, i assumed you didn't need ' around the variable since your 1 statement worked, but in anycase try kicking it with this
SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID ='" & sessionID & "'" i"m just adding ' around the variable. also, did you print sessionID? what's it's value? |
|
#11
|
|||
|
|||
|
ack, you're starting to sound like my boss saying my code doesn't work when it does
![]() |
|
#12
|
|||
|
|||
|
hehehe, just one more thing...
Do you know how to do this: When a frame page loads, (for example the bottom frame) can i make that trigger the top frame page to refresh? thanks again! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Help with simple database relationships |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|