PC Review


Reply
Thread Tools Rate Thread

Best way to connect to Sybase DB?

 
 
=?Utf-8?B?Vk1J?=
Guest
Posts: n/a
 
      8th Nov 2005
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.
 
Reply With Quote
 
 
 
 
CT
Guest
Posts: n/a
 
      9th Nov 2005
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.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"VMI" <(E-Mail Removed)> wrote in message
newsB5C472A-37A0-401F-A2AA-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
=?Utf-8?B?VmVua2F0X0tM?=
Guest
Posts: n/a
 
      9th Nov 2005
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/onlinebook...View;pt=asnetg

0100e


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

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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sybase ASE client to connect to Sybase System 11 =?Utf-8?B?Q2hyaXMgRGF2b2xp?= Microsoft ADO .NET 1 15th Sep 2006 09:54 PM
Best way to connect to Sybase ASE 11.5? =?Utf-8?B?Vk1J?= Microsoft C# .NET 0 8th Nov 2005 09:40 PM
how to connect to sybase macro Microsoft C# .NET 2 14th Jul 2005 10:55 AM
how to connect to sybase xinhuanet.com Microsoft ASP .NET 1 3rd Jun 2005 04:53 PM
Connect to Sybase Thomas Kehl Microsoft ADO .NET 0 31st Aug 2003 09:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:26 AM.