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