Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    JamesSF is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2014
    Posts
    11

    ADODB error connecting to SQL


    hello

    im getting this error conecting to SQL

    5 [Microsoft][SQL Server Native Client 11.0][SQL Server]Changed database context to 'chronos'.

    with this code

    Code:
    Public Function Connect() As String
                
            On Error GoTo ErrHandler
    
             
             Dim CN As ADODB.Connection
             Set CN = New ADODB.Connection
    
    
            CN.ConnectionString = "DSN=chronosTEST;"
            CN.Open
            
    
            
    ErrHandler:
                   
            Err.Raise Err.Number
            Resume Next
            
    End Function
    Actually, I get this with any connect string I try

    Code:
    CN.Open "Driver={SQL Server};Data Source=s-tc-sql01;Database=chronos;User ID=user;Password=password"
    CN.Open "Driver={SQL Server Native Client 11.0};server=sql.transcom-solutions.com;Database=chronos;User ID=user;Password=password;Trusted_Connection=yes"
    CN.Open "Provider=MSDASQL;Driver={SQL Server Native Client 11.0};server=sql.transcom-solutions.com;Database=chronos;User ID=user;Password=password"
    what am I missing? is it a problem with the SQL server?

    thanks in advance!

  2. #2
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Daft question - can you get any response from it - are you normally able to ping that server ?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    JamesSF is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2014
    Posts
    11
    yes - see screenshot - both internal and external name


    Click image for larger version. 

Name:	Capture.JPG 
Views:	24 
Size:	67.4 KB 
ID:	36657

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125

  5. #5
    JamesSF is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    11
    thanks - replacing the previous line with this

    Code:
    CN.Open "Provider=SQLOLEDB;Data Source=10.160.0.4;Initial Catalog=chronos;User ID=user;Password=password"


    gives a new error

    5 Invalid procedure call or argument


  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    I believe you have SQL Server Native Client 11 - try Provider=SQLNCLI11

    https://www.connectionstrings.com/sq...ledb-provider/

  7. #7
    JamesSF is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    11
    I had downloaded the Microsoft® OLE DB Driver 18 for SQL Server
    when I got the error

    if I change the provider to this

    Code:
    CN.Open "Provider=SQLNCLI11;Data Source=10.160.0.4;Initial Catalog=chronos;User ID=user;Password=password"
    I get the same error

    5 Invalid procedure call or argument


  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Do you have the MS Management Studio installed? Can you log in and see the database objects using the user/password you are trying in the connection strings? What permissions does the user have?

    Cheers,
    Vlad

  9. #9
    JamesSF is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    11
    Quote Originally Posted by Gicu View Post
    Do you have the MS Management Studio installed? Can you log in and see the database objects using the user/password you are trying in the connection strings? What permissions does the user have?

    Cheers,
    Vlad


    yes - can log in as the user in the connection string. can view data and edit

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    And can you link a SQL table from the SQL chronos db into your Access app?

  11. #11
    JamesSF is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    11
    yes i can using the same machine DSN referenced in the first post.

  12. #12
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    The DSN refers to chronosTEST db, what happens if you change the DSN to attach to chronos db instead and test the connection in the DSN dialog?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    JamesSF is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    11
    Quote Originally Posted by Minty View Post
    The DSN refers to chronosTEST db, what happens if you change the DSN to attach to chronos db instead and test the connection in the DSN dialog?
    good observation!

    however, that is labeled test so its not used in production.

    just to be sure - I changed to the code to another machine DSN - the live one used inside access

    Code:
    CN.ConnectionString = "DSN=s-tc-sql01;"
    I get this error - 5 Invalid procedure call or argument

    here is setup for that DSN

    Click image for larger version. 

Name:	1.JPG 
Views:	11 
Size:	36.4 KB 
ID:	36668

    Click image for larger version. 

Name:	2.JPG 
Views:	11 
Size:	32.7 KB 
ID:	36669

    Click image for larger version. 

Name:	3.JPG 
Views:	11 
Size:	40.2 KB 
ID:	36670

    Click image for larger version. 

Name:	4.JPG 
Views:	11 
Size:	41.7 KB 
ID:	36671

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    So you have a live Access application running on the same machine/user that is working and another trying to connect to a different SQL db (chronos)? What kind of authentication is the SQL server set up for, is it in mixed mode or Windows authentication only? You use Windows authentication in the DSN pics, can you check in SSMS what permissions are attached to the user for the chronos db?

  15. #15
    JamesSF is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    11
    the live acccess db and a blank one with just this connection string are on the same machine.

    here are the screenshots for that user account

    Click image for larger version. 

Name:	a.JPG 
Views:	8 
Size:	57.4 KB 
ID:	36680

    Click image for larger version. 

Name:	b.JPG 
Views:	9 
Size:	40.4 KB 
ID:	36681

    Click image for larger version. 

Name:	c.JPG 
Views:	9 
Size:	56.8 KB 
ID:	36682

    Click image for larger version. 

Name:	d.JPG 
Views:	9 
Size:	59.9 KB 
ID:	36683

    Click image for larger version. 

Name:	e.JPG 
Views:	9 
Size:	42.8 KB 
ID:	36684

    thanks!

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. ADODB.recordset Not Defined Error
    By jdashm in forum Reports
    Replies: 1
    Last Post: 12-18-2018, 11:48 AM
  2. Replies: 3
    Last Post: 05-01-2018, 12:16 PM
  3. Replies: 0
    Last Post: 02-13-2015, 02:24 PM
  4. Error Handling with ADODB Recordset Object
    By Aaron5714 in forum Programming
    Replies: 3
    Last Post: 12-27-2012, 04:02 PM
  5. Replies: 1
    Last Post: 04-30-2012, 10:09 AM

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