none
Connect to sybase from VBA RRS feed

  • Question

  • Hi

    I am trying to connect to a sybase database from excel macro. The code is shown below:

    constr = "Provider=Sybase.ASEOLEDBProvider;" _
           & "DSURL='file://c:\sybase\ini\sql.ini?TSSRV';" _
           & "Database=DBSG;" _
           & "UID=unm;" _
           & "PWD=pass;" _
           & "APP=Testing;"
    Set con = New ADODB.Connection
    con.Open

    But when I try to execute the code, I receive the following error, on the con.Open statement

    -2147467259
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    But I have sybase database installed on the system and I can connect to the sybase database from this system. Please help me to find the error location.

    Monday, June 10, 2013 10:16 AM

All replies

  • You did not set the connection string to the connection object:

    constr = "Provider=Sybase.ASEOLEDBProvider;" _
           & "DSURL='file://c:\sybase\ini\sql.ini?TSSRV';" _
           & "Database=DBSG;" _
           & "UID=unm;" _
           & "PWD=pass;" _
           & "APP=Testing;"
    Set con = New ADODB.Connection
    con.ConnectionString = constr
    con.Open


    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Tuesday, June 11, 2013 12:48 AM
  • You did not set the connection string to the connection object:

    constr = "Provider=Sybase.ASEOLEDBProvider;" _
           & "DSURL='file://c:\sybase\ini\sql.ini?TSSRV';" _
           & "Database=DBSG;" _
           & "UID=unm;" _
           & "PWD=pass;" _
           & "APP=Testing;"
    Set con = New ADODB.Connection
    con.ConnectionString = constr
    con.Open


    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    Thanks a lot. That is a very bad mistake. How did I forget to specify connection string in the connection oblect.

    But still there is an error. Now I am getting the error,

    -2147467259
    Invalid server name was specified.

    But I am using proper INI and proper servername. I wrote the ini filename ,
    'file://c:\sybase\ini\sql.ini?TSSRV' , in command prompt and it opened the correct ini and there is an entry for the server TSSRV in that ini. Even I executed dsedit from command prompt and located the server these also.The database name is correct as well. Can anybody help me in this regard?
    Tuesday, June 11, 2013 5:08 AM
  • @MR_SQL_Learner
    I do not know much about Sysbase connection strings, but this mix of \ with / slashes in the DSURL is kind strange. I would try some variations on that, like 'c:\sybase\ini\sql.ini?TSSRV' or other variations. However, visit Rod Gill's link.

    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

    • Proposed as answer by by my name Thursday, November 21, 2013 9:17 AM
    Tuesday, June 11, 2013 8:37 AM