How to connect to a Sybase Server v12.5 using OLEDB ConnectionString RRS feed

  • Question

  • User1207145862 posted

    I am trying to do a simple connection string in asp.net to link to a Sybase v12.5 database on a sun solaris unix server. I have looked on the internet via google, and i think i have found the connection string that i need. The page found also talked about a .ids file. This file has now been created as the web page dictated by the sybase administration tool.

    Now the snippet of code below  shows what i have in my asp.net page. But when i run it i get the following error.

                       Error : Sybase ASE OLE DB Provider - Cannot connect to data source.

    I have used the start->setting->control panel->administrator tools-> DataSource (ODBC) to create a odbc entry to the server and databse, and this tested ok. Which i think shows that my machine can connect to the database in question.

    The questions i have is 1) where do you put the .ids file ( the dba who created the file, emailed it to me and i placed it under c:\sybase\oledb)
    2) why am i getting the error, does any one know the correct settings for the connectionstring 3) what sybase drivers do i need on my machine, if i have the wrong one?

    Thank you all again for your time and considerations


    oOLEDBCon.ConnectionString = "Provider=Sybase.ASEOLEDBProvider.2;Server Name=SYBTS1FOA,9917;Initial Catalog=UTILS;User Id=stahxb;Password=password1"

    SQLCmd= "select * from application_codes"

    Dim apt1 As New System.Data.OleDb.OleDbDataAdapter(SQLcmd, oOLEDBCon)

    apt1.Fill(dsDataSet, "MQSI_LOG")

    Catch ex As Exception

    lblError.Text = "Error : " & ex.Source & " - " & ex.Message

    End Try

    Friday, November 18, 2005 12:55 PM

All replies

  • User634179318 posted

    Hi there

    I just knocked up a quick app to try this and set up an ODBC DSN which I tested and conencted through the ODBC panel.

    Wrote the following:


    static void Main(string[] args)
                    string connectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    OdbcConnection connection = new OdbcConnection();
    connection.ConnectionString = connextionString;        
            catch(Exception e)

    I then declared the following in app.config:

    <add key="ConnectionString" value="DSN=InfraScanDSN;UserName=user; Password=password"/>



    Thursday, December 15, 2005 3:04 AM
  • User634179318 posted

    Forgot to add:

    If you are using a normal line then it seems that sybase requiers the port to be adressed explicitly not with a comma after the dbname:


    dsConnectionString = "Provider=Sybase.ASEOLEDBProvider;Server Name=ServerName;Server Port Address=XXXX;Initial Catalog=DIRECTORY;User ID=XXX;Password=XXXX"

    Thursday, December 15, 2005 3:08 AM
  • User937951810 posted

    I just had the same error. A guru here told me how to deal with it:

    1) Check the Server is defined in


    2) Check the Data Source exists in:


    Good luck!!


    Wednesday, January 4, 2006 4:50 PM
  • User308568317 posted

    Álvaro... thanks a bunch! that was extremely helpful and solved my problem. 

    Wednesday, April 14, 2010 4:49 PM
  • User370135452 posted


    Even I'm facing the same issue. I verified as Alvaro said. But I couldn't resolve the issue. Can someone help me to resolve the problem?

    The server exists. and the provider is working from sydaadm.exe. But when I execute the code below, it throws cannot connect to datasource exception.

    OleDbConnection conn;
                    OleDbDataReader rdr;
                    OleDbCommand cmd;
                    string connectionString = "Provider=Sybase ASE OLE DB Provider;Server Name=XXX;Datasourcce=XXXX;User ID=XXXX;Password=XXX";
                    conn = new OleDbConnection(connectionString);

                    string sql = "SELECT TOP 10 * FROM test";
                    cmd = new OleDbCommand(sql, conn);
                    cmd.CommandType = CommandType.Text;
                    rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                        Console.WriteLine(rdr["one"].ToString() + " " + rdr["two"] + " " + rdr["three"]);


    Tuesday, November 11, 2014 8:57 AM