|
-
Jun 3rd, 2003, 12:33 PM
#1
Thread Starter
Addicted Member
Maybe it's better asked over here *RESOLVED*
Here's my code for those who haven't seen it:
VB Code:
Option Explicit
Private cn As ADODB.Connection
Private rs As ADODB.Recordset
Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C:\mydatabase.mdb"
cn.Open
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM game WHERE hometeamid = '" & Text1.Text & "' OR awayteamid = '" & Text1.Text & "'"
rs.MoveFirst
Do Until rs.EOF = True
Combo1.AddItem rs.Fields("gameid")
rs.MoveNext
Loop
rs.MoveFirst
End Sub
I get an error message on my SELECT statement saying:
Code:
Run-time error '3709';
The connection cannot be used to perform this operation. It is either
close or invalid in this context.
Anyone have an idea as to why? Am I doing something wrong when I open the recordset?
Last edited by run_GMoney; Jun 3rd, 2003 at 04:09 PM.
Place Your VBForums Ad Here
-
Jun 3rd, 2003, 02:56 PM
#2
PowerPoster
Maybe this will work
dim sql as string
sql = "SELECT * FROM game WHERE hometeamid = '" & Text1.Text & "' OR awayteamid = '" & Text1.Text & "'"
rs.Open sql, Cn, adOpenKeyset, adLockReadOnly, adCmdText
-
Jun 3rd, 2003, 03:04 PM
#3
Fanatic Member
You didn't associate a valid cn object for your rs. After you add you select statement add the cn object and any other params you need.
-
Jun 3rd, 2003, 04:08 PM
#4
Thread Starter
Addicted Member
Yeah actually I should have altered my subject on the thread. I figured that out about 3 hours ago. Thanks for the reply though
Place Your VBForums Ad Here
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
|