Becca
07-20-2003, 12:06 AM
Hi,
I'm having a problem with some code (I'm really new to doing anything with database - sorry!)
I'm making a program that will randomise results found in a database, and I'm displaying them in a listbox.
I have already declared the ADO connection, and Code is the name of the primary key I want to get information from.
It's just that when I go to randomise, I have a problem with the part of the code:
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\WINDOWS\Desktop\Music.mdb;"
MyConn.Open
'Set MyRecSet = MyConn.Execute("SELECT Code FROM Music_Table")
Set MyRecSet = New ADODB.Recordset
MyRecSet.Open "SELECT Code FROM Music_Table", MyConn, adOpenKeyset, adLockOptimistic
IntCo = MyRecSet("Code")
Do
PKey(k) = MyRecSet.[Code]
MyRecSet.MoveNext
k = k + 1
Loop Until MyRecSet.EOF
There's a problem with the MyRecSet.[Data], and it says Method or Datamember not found. I don't understand what the problem is, since that's the data I want to retrieve. Do you have any idea what the problem is? It's ok if you can't help me, I just thought I'd ask...
thankyou!! :)
Becca
I'm having a problem with some code (I'm really new to doing anything with database - sorry!)
I'm making a program that will randomise results found in a database, and I'm displaying them in a listbox.
I have already declared the ADO connection, and Code is the name of the primary key I want to get information from.
It's just that when I go to randomise, I have a problem with the part of the code:
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\WINDOWS\Desktop\Music.mdb;"
MyConn.Open
'Set MyRecSet = MyConn.Execute("SELECT Code FROM Music_Table")
Set MyRecSet = New ADODB.Recordset
MyRecSet.Open "SELECT Code FROM Music_Table", MyConn, adOpenKeyset, adLockOptimistic
IntCo = MyRecSet("Code")
Do
PKey(k) = MyRecSet.[Code]
MyRecSet.MoveNext
k = k + 1
Loop Until MyRecSet.EOF
There's a problem with the MyRecSet.[Data], and it says Method or Datamember not found. I don't understand what the problem is, since that's the data I want to retrieve. Do you have any idea what the problem is? It's ok if you can't help me, I just thought I'd ask...
thankyou!! :)
Becca