|
-
Jul 3rd, 2008, 10:56 AM
#1
Thread Starter
Addicted Member
Opening 2 or more tables?
How can I open two tables at once,
I tried this code but it didn't worked for me:
vb Code:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockReadOnly
rs.Open "SELECT * FROM avatar,singleplayername", conn, adOpenStatic, adLockOptimistic
swfUserProfile.SetVariable "txtPlayerName", rs!playerName
swfPictureAvatar.LoadMovie 1, rs!avatarFile
swfPictureAvatar.Movie = rs!avatarFile
rs.Close
Set rs = Nothing
Need Help
-
Jul 3rd, 2008, 11:00 AM
#2
Re: Opening 2 or more tables?
Sorry each table needs a sperate select statement. Are they related in some way?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jul 3rd, 2008, 11:03 AM
#3
Thread Starter
Addicted Member
Re: Opening 2 or more tables?
They came from the same database, how can I fix it?
-
Jul 3rd, 2008, 11:12 AM
#4
Re: Opening 2 or more tables?
You write two select statements. Or if the tables are related in someway (they hold information about someone some stuff in one table and other stuff in the other) then you do a select from both tables using an Inner Join.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jul 6th, 2008, 09:59 PM
#5
Thread Starter
Addicted Member
Re: Opening 2 or more tables?
Can I have an example of using select statement with Inner Join?
Thanks. Sorry for bothering.
-
Jul 7th, 2008, 03:35 AM
#6
Re: Opening 2 or more tables?
You can, but we need information from you first.. what fields are in each table? which field(s) are used to link them together?
It would probably help if you show a couple of example rows of data from each table.
-
Jul 7th, 2008, 04:43 AM
#7
Thread Starter
Addicted Member
Re: Opening 2 or more tables?
These are the fields for the avatar table:
1. avatarNumber
2. avatarName
3. avatarSize
4. avatarFile <----- Location only
These are fields for the singleplayername table:
1. playerNumber
2. playerName
I'm just trying to call them both all at once at the Form_Load()
So the user can choose his or her name and avatar.
-
Jul 7th, 2008, 05:07 AM
#8
Re: Opening 2 or more tables?
Ok, there appears to be no related data at all - what we expected to see was something like the Player table having a field (perhaps called avatarNumber) which refers to a specific row in the Avatar table.
As that isn't the way you have it, a Join is not apt. Instead you should open two separate Recordsets, one for each table.
-
Jul 8th, 2008, 01:50 AM
#9
Member
Re: Opening 2 or more tables?
 Originally Posted by si_the_geek
Ok, there appears to be no related data at all - what we expected to see was something like the Player table having a field (perhaps called avatarNumber) which refers to a specific row in the Avatar table.
As that isn't the way you have it, a Join is not apt. Instead you should open two separate Recordsets, one for each table.
hey i remember that you can do multiple select right??? that is why there is "NEXTRECORDSET" procedure on ADO?? i dont know if this is correct...
but how to do this i do not remember...try putting this ";" after each statement...
-
Jul 8th, 2008, 02:52 AM
#10
Re: Opening 2 or more tables?
That would be possible but wouldn't really gain much, it would just mean that there was only one recordset variable (with separate code blocks) instead of two - I think belvita would find it less confusing to have two separate ones.
-
Jul 8th, 2008, 02:58 AM
#11
Member
Re: Opening 2 or more tables?
 Originally Posted by si_the_geek
That would be possible but wouldn't really gain much, it would just mean that there was only one recordset variable (with separate code blocks) instead of two - I think belvita would find it less confusing to have two separate ones.
hahaha...im just going with the idea of the two SELECT statements. coz i just remembered that it was kinda' possible..im sorry to have mislead.
-
Jul 8th, 2008, 03:07 AM
#12
Re: Opening 2 or more tables?
There are times when it is a good idea (otherwise it wouldn't be an option!), but in my opinion this isn't one of them.. it is debatable tho, so mentioning it wasn't a bad thing.
-
Jul 8th, 2008, 08:53 AM
#13
Thread Starter
Addicted Member
Re: Opening 2 or more tables?
Two select statement? like this one?
rs.Open "SELECT * FROM avatar"
rs.Open "SELECT * FROM singleplayername"
Is this the right syntax?
I'd tried this but it didn't worked for me.
-
Jul 8th, 2008, 09:28 AM
#14
Re: Opening 2 or more tables?
Something like this:
Code:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM singleplayername", conn, adOpenForwardOnly, adLockReadOnly
swfUserProfile.SetVariable "txtPlayerName", rs!playerName
rs.Close
rs.Open "SELECT * FROM avatar", conn, adOpenForwardOnly, adLockReadOnly
swfPictureAvatar.LoadMovie 1, rs!avatarFile
swfPictureAvatar.Movie = rs!avatarFile
rs.Close
Set rs = Nothing
Note however that as you are not using a Where clause with the SQL statements, you cannot tell which record will be read from each table (assuming each table has more than one record).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|