C # operate the Sybase Database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.