C # Call the Sybase Stored Procedure

Source: Internet
Author: User

 

1: Reference ODBC namespace

Using system. Data;
Using system. Data. ODBC;

2. Establish a connection

Connstr = "driver = {sybase system 11}; srvr = database name; uid = username; Pwd = password ";

Odbcconnection conn = new odbcconnection (connstr );

3: Call the Stored Procedure

Conn. open ();
Odbccommand cmd = new odbccommand ();
Cmd. Connection = conn;
Cmd. commandtype = commandtype. storedprocedure;
Cmd. commandtext = "database name. DBO. Stored Procedure name ?,?,? ";

Odbcparameter para1 = cmd. Parameters. Add ("@ para1", odbctype. varchar );
Para1.direction = parameterdirection. input;
Para1.value = value1;

Odbcparameter para2 = cmd. Parameters. Add ("@ para2", odbctype. varchar );
Para2.direction = parameterdirection. input;
Para2.value = value2;

Odbcparameter para3 = cmd. Parameters. Add ("@ para3", odbctype. varchar );
Para3.direction = parameterdirection. input;
Para3.value = value3;

Cmd. nonquery ();
Cmd. Dispose ();
Conn. Close ();

Conn. Dispose ();

 

4: I have been searching for it online for a while. Now I want to sum it up.

Haha :--)

Hope it will be useful in the future!

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.