Sybase Database Connection String in C#

In this article, I have listed C# code snippets of connection string for Sybase Database.


Sybase Database Connection String in C#:

Connection String provide the required information to the driver that tells where to find the default connection information. Optionally, you are allowed to specify attribute=value pairs in the connection string to override the default values stored in the data source.

1. ODBC DSN

using System.Data.Odbc;
var conn = new OdbcConnection();
conn.ConnectionString = 
              "Dsn=DsnName;" + 
              "Uid=UserName;" + 
              "Pwd=Secret;"; 
conn.Open();

2. ODBC – Sybase System 12 (12.5) ODBC Driver

using System.Data.Odbc;
var conn = new OdbcConnection();
conn.ConnectionString = 
              "Driver={SYBASE ASE ODBC Driver};" + 
              "Srvr=ServerName;" + 
              "Uid=UserName;" + 
              "Pwd=Secret;"; 
conn.Open();

3. ODBC – Sybase System 11 ODBC Driver

using System.Data.Odbc;
var conn = new OdbcConnection();
conn.ConnectionString = 
           "Driver={SYBASE SYSTEM 11};" + 
           "Srvr=ServerName;" + 
           "Uid=UserName;" + 
           "Pwd=Secret;"; 
conn.Open();

4. ODBC – Intersolv 3.10 ODBC Driver

using System.Data.Odbc;
var conn = new OdbcConnection();
conn.ConnectionString = 
        "Driver={INTERSOLV 3.10 32-BIT Sybase};" + 
        "Srvr=ServerName;" + 
        "Uid=UserName;" + 
        "Pwd=Secret;"; 
conn.Open();

5. ODBC — SQL Anywhere

using System.Data.Odbc;
var conn = new OdbcConnection();
conn.ConnectionString = 
         "ODBC;" + 
         "Driver={Sybase SQL Anywhere 5.0};" + 
         "DefaultDir=c:\myfolder\;" + 
         "Dbf=c:\mypath\dbname.db;" + 
         "Uid=UserName;" + 
         "Pwd=Secret;" + 
         "Dsn="""";";     // Must be included!
conn.Open();

6. OleDb — Sybase Adaptive Server Enterprise (ASE)

using System.Data.OleDb;
var conn = new OleDbConnection();
conn.ConnectionString = 
              "Driver=Sybase.ASEOLEDBProvider;" + 
              "Server Name=ServerName,5000;" +  // replace 'Server Name' with 'Srvr'
              "Initial Catalog=DataBaseName;" + //'Initial Catalog' with 'Catalog'
              "User id=UserName;" + 
              "Password=Secret;"; 
conn.Open();

7. NET DataProvider from Sybase

using Sybase.Data.AseClient;
var conn = new AseConnection();
conn.ConnectionString = 
              "Data Source=ServerName;" + 
              "Initial Catalog=DataBaseName;" + 
              "User id=UserName;" + 
              "Password=Secret;"; 
conn.Open();

– Article ends here –

If you have any questions, please feel free to share your questions or comments on the comment box below.

Recommended:   Text Database Connection String in C#
Share this:
We will be happy to hear your thoughts

Leave a reply

Troubleshootyourself
Logo