ASP. NET call stored procedure 1

Source: Internet
Author: User
Tags oracleconnection

1, incoming parameters, outgoing parameters

public int Getteam1id (string userId)
{
int team1id =-1;
String strspname = "PDM. Prodname_phoneinfo_pkg. GET_TEAM1_ID ";
using (oracleconnection dbConnection = new OracleConnection (helper.mconnectionstring))
{
Dbconnection.open ();

                OracleCommand DbCommand = new OracleCommand ();
                Dbcommand.commandtype = CommandType.StoredProcedure;
                Dbcommand.commandtext = Strspname;
                Dbcommand.connection = dbConnection;

DBCOMMAND.PARAMETERS.ADD ("ps_user_id", userId);
DBCOMMAND.PARAMETERS.ADD ("ps_team1_id", Oracletype.number);
dbcommand.parameters["ps_team1_id"]. Direction = ParameterDirection.Output;

Try
{
Dbcommand.executenonquery ();
team1id = Int. Parse (dbcommand.parameters["ps_team1_id"). Value.tostring ());
}
Catch
{
Dbconnection.close ();
Dbconnection.dispose ();
}
if (dbconnection.state = = ConnectionState.Open)
{
Dbconnection.close ();
}
Dbconnection.dispose ();

}
return team1id;

}

2,

The reading of a stored procedure is generally
SqlConnection con = new SqlConnection (configurationmanager.appsettings["Constr"]);
SqlCommand cmd;
It's a form.
cmd = new SqlCommand ("sp_ your process", con);
Cmd.commandtype = CommandType.StoredProcedure;
Cmd. Parameters.Add (New SqlParameter ("@Type", SqlDbType.Int));

Cmd. Parameters.Add (New SqlParameter ("@YourName", SqlDbType.NVarChar, 40));
Cmd. parameters["@YourName"]. Value = GoodsName.Text.Trim ();

Gridview1.datasource = GetDataSet (your database operation, as the source of the display);
Gridview1.datakeynames = new string[] {"id"};
Gridview1.databind ();
This is the GridView binding method.

ASP. NET call stored procedure 1

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.