Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC error 3151 - connection failed

Status
Not open for further replies.

gottaski

Programmer
Jan 4, 2001
17
US
I'm using Access as a front end to a SQL Sever database -- via linked tables. I'm generating a pass-thru query to return a recordset. When I run the query for the first time from a form, I get the error -- ODBC error 3151 - connection to *my database* failed.

Now, if I close the form, open it again and re-run the query, everything works fine.

Also, the pass-thru query is created before the error is occuring so I don't understand why the connection failed when it actually connected and returned records.

Does anyone have any clue????

Here is the line that is failing:
Set db = CurrentDb
Set rs = db.OpenRecordset("QueryCandidates") -- this is my pass-thru query and if i view it from the query window, it works fine, just not thru code. also, i have tried using this code

Set db = CurrentDb
Set rs = db.OpenRecordset("QueryCandidates", dbOpenDynaset, dbSeeChanges)

Any help would be greatly appreciated.

Thanks in advance
 
Please ignore this thread. I finally figured it out. I was using a trusted connection in my query and it didn't like it. Once I changed the trusted connection to "no", it worked.

Thanks,
MJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top