应该不可能完全用控件来实现吧,
这是我调用的一个存储过程
private void AddRow_Click(object sender, System.EventArgs e)
{
//创建数据库操作对象
SqlCommand MyCommand =new SqlCommand();
//SqlConnection MyConn=new SqlConnection(ConfigurationSettings.AppSettings["TSConn"].ToString());
MyCommand.Connection=conn;
conn.Open();
//指定要调用的存储过程
if(Page.IsValid==true)
{
try
{
MyCommand.CommandText="ts_insert_factoryvalue";
MyCommand.CommandType=CommandType.StoredProcedure;
SqlParameter para1=new SqlParameter("@FactoryID",SqlDbType.VarChar,20);
SqlParameter para2=new SqlParameter("@FactoryName",SqlDbType.VarChar,100);
SqlParameter para3=new SqlParameter("@PollutantCode",SqlDbType.Char,3);
SqlParameter para4=new SqlParameter("@PollutantName",SqlDbType.VarChar,30);
SqlParameter para5=new SqlParameter("@Class",SqlDbType.VarChar,30);
SqlParameter para6=new SqlParameter("@value",SqlDbType.Float,8);
SqlParameter para7=new SqlParameter("@PreDeclareYear",SqlDbType.Char,4);
SqlParameter para8=new SqlParameter("@OutAmount",SqlDbType.VarChar,30);
SqlParameter para9=new SqlParameter("@code",SqlDbType.VarChar,8);
para1.Value=FID;
para2.Value="";
para3.Value="";
para4.Value="";
para5.Value="";
para6.Value="1";
para7.Value="";
para8.Value="";
para9.Value=code;
MyCommand.Parameters.Add(para1);
MyCommand.Parameters.Add(para2);
MyCommand.Parameters.Add(para3);
MyCommand.Parameters.Add(para4);
MyCommand.Parameters.Add(para5);
MyCommand.Parameters.Add(para6);
MyCommand.Parameters.Add(para7);
MyCommand.Parameters.Add(para8);
MyCommand.Parameters.Add(para9);
MyCommand.ExecuteNonQuery();
}
catch(Exception error)
{
Response.Write(error.ToString());
}
finally
{
//Response.Write("<script language=/"javascript/">alert(/"插入数据成功/")</script>");
//Message.Text="<script language=/"javascript/">alert(/"插入数据成功!/")</script>";
conn.Close();
}
DataGridDataBind();
}
}
希望能帮到你。