Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 ODBC--Connection to "databaseName" failed

Author  Topic 

rum23
Yak Posting Veteran

77 Posts

Posted - 2008-10-19 : 17:31:38
I get the error "ODBC--Connection to 'databasename" failed". Error number is 3151. This error is in ACCESS 2007 and the tables are linked to SQL Server 2005 database tables. This error occurs randomly but it appears quite frequently. Basically, this happens if a series of queries are executed in MS access. Usually, the first query executes fine and while executing the 2nd one, it bombs. Its sporadic. Sometimes, the 1st and the 2nd queries execute just fine but bombs on the 3rd one. I did google on this and tried couple of resolutions but none of them worked. I have setup a odbc datasource for the database in SQL Server 2005. What could be causing this error? MS ACCESS 2007 and SQL Server 2005 are on one machine (locally on a developement machine). Please let me know if you need more details.

Your help is appreciated! Thanks!

rum23
Yak Posting Veteran

77 Posts

Posted - 2008-10-19 : 18:11:40

Anybody??? Please help
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2008-10-21 : 06:05:57
I'd suspect a coding problem....maybe your variable holding for database connection string is being cleared/initialised/nullified. Can you embed some tracing statements into your code?
Go to Top of Page

rum23
Yak Posting Veteran

77 Posts

Posted - 2008-10-21 : 15:38:14

I have looked at this over and over again and I am reaching a dead end. Bascially I get this error when doing an OpenRecordset() method. In this one function, I do a series (about 10 or so) of OpenRecordset() calls to retrieve data from different tables. And sometimes, the method call fails, when doing a OpenRecordset() the 2nd time and sometimes it fails 4th time and sometimes it fails the 1st time. Its very inconsistent as to when the error bombs.

My db is set as follows

Set db = Currentdb
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)

The exact error message is "ODBC--connection to 'SQL ServerWINXP06' failed.". WINXP06 is my machine name. I have search the entire code to see if there are any loose ends, but found none.

Please help.
Go to Top of Page

smithersgs
Starting Member

17 Posts

Posted - 2009-02-05 : 15:03:01
I know it might be too late, but for someone out there who experieces the same issue.
In my case my Access database has some linked tables to SQL Server. One of them lost its connection somehow. I deleted it and relinked.
You can check if any linked table lost its connection by opening it.
Go to Top of Page

osupratt
Posting Yak Master

238 Posts

Posted - 2009-02-11 : 10:19:26
So when you say linked tables; when you go to the tables area can you double click on the tables in question and does the data show or does it give you an ODBC error?

Go to Top of Page

punkari
Starting Member

1 Post

Posted - 2009-08-14 : 07:28:19
You might need to login to the linked table before using it. See [url]http://support.microsoft.com/kb/245587[/url].
Go to Top of Page

LeeG
Starting Member

1 Post

Posted - 2010-08-19 : 17:53:51
Hey smithersgs, did you ever get this problem solved. I have the same problem.
Go to Top of Page

simone334
Starting Member

1 Post

Posted - 2011-03-01 : 10:12:49
I have the same problem, Access query to linked sql2000 tables fails at fourth time that I launch it, I tryed to disable all possible timeout, firewall and antivir but nothing. thanks
Go to Top of Page

TSky
Starting Member

1 Post

Posted - 2012-04-25 : 23:02:22
I got the same error whose number is 3151. In my case, when modifying former version of access file (*.mdb) with Access 2007, this error occurs randomly and could not create linktable via ODBC. After connection was established by hand, my code seems to go well for a while. When I tried same code in a new Access accdb file, no error occured in ten times trial.

I have abandoned to use the linktable and now am trying to copy data via ADO.

Thanks,
Go to Top of Page
   

- Advertisement -