62,243
社区成员




protected void button_a_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NetdbConnectionString"].ConnectionString);
try
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "product_add_HbxzTB";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param;
string ID ="123";
param = cmd.Parameters.AddWithValue("@Iproduct_ID", ID);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
string gcxz ="456";
param = cmd.Parameters.AddWithValue("@qcxz", gcxz);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
string hcxz ="789";
param = cmd.Parameters.AddWithValue("@hcxz", hcxz);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
}
finally
{
con.Close();
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[product_add_HbxzTB]
@Iproduct_ID nchar(32),
@qcxz nchar(10),
@hcxz nchar(10)
as
insert into HbxzTB (Iproduct_ID,qcxz,hcxz) values(@Iproduct_ID,@qcxz,@hcxz)
//你不执行他,要他怎么反应?
using( SqlDataAdapter da = new SqlDataAdapter(cmd) )
{
DataSet ds = new DataSet();
da.Fill(ds);
cmd.Parameters.Clear();
return ds;
}
protected void button_a_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NetdbConnectionString"].ConnectionString);
try
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "product_add_HbxzTB";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param;
string ID = "123";
param = cmd.Parameters.AddWithValue("@Iproduct_ID", ID);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
string gcxz = "456";
param = cmd.Parameters.AddWithValue("@qcxz", gcxz);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
string hcxz = "789";
param = cmd.Parameters.AddWithValue("@hcxz", hcxz);
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
cmd.EndExecuteNonQuery();
}
finally
{
con.Close();
}
}
try{
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
finally
{
con.close();
}