Best way to connect to Sybase DB?

G

Guest

What's the best way to connect to a Sybase database? I tried it with
Microsoft.Odbc, but it's giving me problems when I I run it in another PC.

Is there a better connection method? I just need to run a Select query that
fills a dataset. Any examples would be appreciated.

Thanks.
 
C

CT

Odbc should be fine, but obviosuly the driver must be installed on the PC
from which you run your app. In addition, if you're using a DSN you also
need to register it on the PC from which you run your app. You don't say
which Sybase you want to connect to, but Sybase has a number of
driver/providers for .NET and sample code, so you might want to take a look
at their Web site.
 
G

Guest

Dear VMI,


CONNECTING TO SYBASE THROUGH VARIOUS MEANS
***************************************

sybase

ODBC
====
Standard Sybase System 12 (or 12.5) Enterprise Open Client:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Driver={SYBASE ASE ODBC Driver};Srvr=Aron1;Uid=username;Pwd=password"



Standard Sybase System 11:
~~~~~~~~~~~~~~~~~~~~~~~~~~
"Driver={SYBASE SYSTEM 11};Srvr=Aron1;Uid=username;Pwd=password;"


Intersolv 3.10:
~~~~~~~~~~~~~~~

"Driver={INTERSOLV 3.10 32-BIT Sybase};Srvr=Aron1;Uid=username;Pwd=password;"



Sybase SQL Anywhere (former Watcom SQL ODBC driver):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"ODBC; Driver=Sybase SQL Anywhere 5.0;

DefaultDir=c:\dbfolder\;Dbf=c:\mydatabase.db;Uid=username;Pwd=password;Dsn="""""

Note!:
======
The two double quota following the DSN parameter at the end are escaped
quotas (VB syntax), you

may have to change this to your language specific escape syntax. The empty
DSN parameter is

indeed critical as not including it will result in error 7778.

**************************************************************
OLEDB
=====
Adaptive Server Anywhere (ASA):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Provider=ASAProv;Data source=myASA"


Adaptive Server Enterprise (ASE) with Data Source .IDS file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Provider=Sybase ASE OLE DB Provider; Data source=myASE"

Note:
=====
that you must create a Data Source .IDS file using the Sybase Data
Administrator. These .IDS

files resemble ODBC DSNs.


Adaptive Server Enterprise (ASE):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Provider=Sybase.ASEOLEDBProvider;Srvr=myASEserver,5000;Catalog=myDBname;User

Id=username;Password=password"

- some reports on problem using the above one, try the following as an
alternative -

"Provider=Sybase.ASEOLEDBProvider;Server Name=myASEserver,5000;Initial
Catalog=myDBname;User

Id=username;Password=password"

This one works only from Open Client 12.5 where the server port number
feature works, allowing

fully qualified connection strings to be used without defining any .IDS Data
Source files.

**************************************************************
AseConnection (.NET)
=====================

Standard:
~~~~~~~~~

"Data
Source='myASEserver';Port=5000;Database='myDBname';UID='username';PWD='password';"



Declare the AseConnection:
~~~~~~~~~~~~~~~~~~~~~~~~~~

C#:
===
using Sybase.Data.AseClient;

AseConnection oCon = new AseConnection();
oCon.ConnectionString="my connection string";
oCon.Open();



VB.NET:
=======
Imports System.Data.AseClient

Dim oCon As AseConnection = New AseConnection()
oCon.ConnectionString="my connection string"
oCon.Open()

**************************************************************


Adaptive Server Enterprise (ASE)
.NET Data Provider
Sybase.Data.AseClient

The ASE .NET Data Provider is an add-on component to the .NET 1.1 Framework
that allows you to

access a Sybase Adaptive Server Enterprise (ASE) database.

Using C#
===========

using Sybase.Data.AseClient;


AseConnection oAseConn = new AseConnection();
oAseConn.ConnectionString = "Data Source=(local);" +
"Initial Catalog=myDatabaseName;" +
"User ID=myUsername;" +
"Password=myPassword"
oAseConn.Open();


Using VB.NET
============

Imports System.Data.AseClient
....
Dim oAseConn As AseConnection = New AseConnection()
oAseConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=myDatabaseName;" & _
"User ID=myUsername;" & _
"Password=myPassword"
oAseConn.Open()

**************************************************************

For Sybase System 11 ODBC Driver
=================================

' VB.NET
=========

Imports System.Data.Odbc


Dim oODBCConnection As OdbcConnection
Dim sConnString As String = _
"Driver={Sybase System 11};" & _
"SRVR=mySybaseServerName;" & _
"DB=myDatabaseName;" & _
"UID=myUsername;" & _
"PWD=myPassword"
oODBCConnection = New OdbcConnection(sConnString)
oODBCConnection.Open()

**************************************************************

For Sybase ASE OLE DB Provider
==============================

VB.NET
========
Imports System.Data.OleDb
....
Dim oOleDbConnection As OleDbConnection
Dim sConnString As String = _
"Provider=Sybase ASE OLE DB Provider;" & _
"Data Source=MyDataSourceName;" & _
"Server Name=MyServerName;" & _
"Database=MyDatabaseName;" & _
"User ID=myUsername;" & _
"Password=myPassword"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()

************************************************************

OLE DB Provider for Sybase Adaptive Server Anywhere (ASA)
oConn.Open "Provider=ASAProv;" & _
"Data source=myASA"


************************************************************************************************

OLE DB Provider for Sybase Adaptive Server Enterprise (ASE)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

oConn.Open "Provider=Sybase ASE OLE DB Provider;" & _
"Data source=myASEServer"
' Or
oConn.Open "Provider=Sybase.ASEOLEDBProvider;" & _
"Srvr=myASEServer,5000;" & _
"Catalog=myDBName;" & _
"User Id=myUserName;" & _
"Password=myUserPassword"
Where:
- The Sybase ASE OLE DB provider from the Sybase 12.5 client CD
- 5000 is the port number for Sybase.

Note: The Open Client 12 Sybase OLE DB Provider fails to work without
creating a Data Source

..IDS file using the Sybase Data Administrator. These .IDS files resemble
ODBC DSNs.

Note: With Open Client 12.5, the server port number feature finally works,
allowing fully

qualified network connection strings to be used without defining any .IDS
Data Source files.



**************************************************************
FOR MORE INFORMATION................

Contents of the Adaptive Server Enterprise ADO.NET Data Provider 1.0 (Core
Documentation Set)

Collection
========================================================

http://sybooks.sybase.com/onlinebooks/group-adonet/asnetg0100e/@Generic__CollectionView;pt=asnetg

0100e


http://www.sybase.com/detail?id=1031000

http://www.sybase.com/products/developmentintegration/datawindownet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top