protected void Button1_Click(object sender, EventArgs e)
{
string strSql="insert into Invoice_Rebate_Customer_L (FORM_ID,LINE_NO) values (@formNo,@lineNo)";
SqlParameter[] paras =new SqlParameter[2];
paras[0] = new SqlParameter("@formNo", SqlDbType.NVarChar);
paras[0].Value = "88888";
paras[1] = new SqlParameter("@lineNo", SqlDbType.Int);
paras[1].Value = 8;
ExecuteSql(strSql, paras, CommandType.Text);
}
void ExecuteSql(string strSql,SqlParameter[] paras,CommandType cmdType)
{
SqlConnection con = new SqlConnection("Server=aukm2;Database=BU;UID=buuser;PWD=buinfo");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = cmdType;
cmd.CommandText = strSql;
foreach (SqlParameter p in paras)
{
cmd.Parameters.Add(p);
}
cmd.ExecuteNonQuery();
con.Close();
}
转载于:https://www.cnblogs.com/Mac_Hui/archive/2009/06/03/1495375.html