C# .NET - how connect c# to sybase

Asked By Dev M on 22-Aug-09 06:02 AM

from client side how to connect c# to sybase database.

thanks advanc

you need to set a reference

Venkat K replied to Dev M on 22-Aug-09 07:23 AM

to the DLL that contains Sybase ASE provider. The DLL is Sybase.DataAseClient.dll. After the reference is set, your code should compile. If you got any error at run-time may be it may request for another dll which is missing. Just add that dll as same you did for the previous.

You can also use the connection string below:

string con = "Dsn=DatasourceName;uid=username;pwd=password;nln=Winsock;na=servername,portNumber;db=DatabaseName;"

Thanks,

Connecting to Sybase Database

Kirtan Patel replied to Dev M on 23-Aug-09 12:33 AM
You Can Connect to Sybase Database using Following Connection String


Data Source=\\myserver\myvolume\mypat;Initial Catalog=mydd.add;User ID=myUsername;Password=myPassword;ServerType=REMOTE;

I guess it is for your POC and not your actual product/application.

[)ia6l0 iii replied to Dev M on 23-Aug-09 02:32 PM
It is a bad design to connect to databases from the client side, as it is prone to disasters. The right approach is to connect to a thin layer between the two , like a webservice for instance, that allows a transparent yet secured access to databases for applications. 

It does not matter if it is Sybase, or some other databases. all applications should follow this as a thumb rule. Moreover, real-life application databases are not open to be accessed from many boxes. They typically have a single TCP port open which allows access from a couple of load balancers/ webservers.