Recently, a vehicle tax collection system project used the sybase database, but I have never learned this database. to connect to this database, I really don't know how to get started. There are many online experts, but I didn't mean it clearly. I have read all the information on the Internet. No good method is found. ODBC, oledb, and other connections have all been tried. But there are various problems. However, the attempt was successful. Now I will share with you. By the way, this code is the best solution to operate Sybase. There are many projects recently, so I won't say much about it. Download the source code.
Database: ase1252_de_win
. Net: source code of vs2008
The bin folder contains three files. You can copy them to your project and use them.
Sybase. Data. aseclient. dll
Sybdrvado11.dll
Sybdrvssl. dll
The code is not analyzed much, and everyone should be able to understand it.
Using system;
Using system. configuration;
Using system. Data;
Using system. LINQ;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. htmlcontrols;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. xml. LINQ;
Using Sybase. Data. aseclient;
Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Aseconnection conn = new aseconnection ("Data Source = '20180101. 202.38.100 '; Port = '000000'; uid = 'sa'; Pwd = ''; database = 'master ';");
Asecommand cmd = NULL;
Asedatareader reader = NULL;
Try
{
Conn. open ();
Cmd = new asecommand ("select * From spt_values", Conn );
Reader = cmd. executereader ();
Gridview1.datasource = reader;
Gridview1.databind ();
Reader. Close ();
Reader. Dispose ();
}
Catch
{
}
}
}
The query result is:
Code download: http://www.cnblogs.com/Files/yangcai/sybaseConnections.rar