Results 1 to 5 of 5
  1. #1
    bazianm is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    9

    Cannot Connect to 'Database' using CurrentProject.Connection

    I have an application that started in Access 2000. I have it running in 2010 now but the code is unchanged. It worked fine in 2003 on XP.



    Here's the problem.

    I am running a SQL command (code to follow) that is dying with an error:

    -2147467259--connection to 'dbname' failed.

    This is happening consistently but only when running in 2010. When I run it in Access 2003 on XP I am fine. All other database operations up until that point (such as setting recordsources for drop downs) work fine. Data from the tables shows up fine. This command does not.

    I tried a decompile/recompile. No go. I even tried updating the structure of the file to accdb with no success.

    I am using ADO/MDAC 2.8. SQL Server 2012 (SP1) with SQL Native Client 2008R2. (I tried it with Native Client 2012 too).

    Here's the basic code:

    Code:
        adoJobRs.ActiveConnection = CurrentProject.Connection
        
        strSql = "SELECT fkTcbHdr FROM dbo_vJobDtlByReel WHERE teJob = '" & prStrTeJobNo & "' AND " _
                   & "itmNo = '" & prStrItmNo & "' AND NZ([testStatus],'') <> 'Void'" _
                   & " ORDER BY testDateTime, fkTcbHdr, temp, tempSeq"
    
        adoJobRs.Source = strSql
        adoJobRs.CursorLocation = adUseClient
        adoJobRs.LockType = adLockReadOnly
        adoJobRs.Open
    Any help would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    I've never seen code like that.

    Review http://allenbrowne.com/ser-29.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe this will help:

    "The Connection Strings Reference"
    http://www.connectionstrings.com/

  4. #4
    bazianm is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    9
    Quote Originally Posted by June7 View Post
    I've never seen code like that.

    Review http://allenbrowne.com/ser-29.html
    Well, I didn't write it but I am kind of stuck with it. Like I said, it works in 2003 on XP. Not in 7.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Code is not etched in stone. I suggest you modify it.

    I have no idea what the CursorLocation property is for. Never seen it, never used it.

    What do you want to do with the recordset?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 07-03-2014, 02:49 PM
  2. Connect System DSN using connection string
    By jbailey4545 in forum Access
    Replies: 0
    Last Post: 11-08-2013, 01:29 PM
  3. Replies: 0
    Last Post: 04-25-2012, 07:59 AM
  4. Replies: 20
    Last Post: 08-08-2011, 01:34 PM
  5. connect to database
    By newaccess in forum Access
    Replies: 22
    Last Post: 04-05-2011, 02:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums