sql存储过程,以及在ASP.NET中的使用
在SQL中建立的存储过程
CREATE PROCEDURE find
(@strName int)
AS
select @strName=rtrim(@strName)
select * from khxxb
where (KHLXZ=@strName)
return
GO
在ASP.NET中的调用:
SqlConnection myconn = new SqlConnection((string)Application["Connstr"]);
SqlCommand mycomm = new SqlCommand();
SqlParameter Param=new SqlParameter("@strName",SqlDbType.Int);
Param.Value="1";
mycomm.Connection=myconn;
mycomm.CommandType=CommandType.StoredProcedure;
mycomm.CommandText="find";
mycomm.Parameters.Add(Param);
myconn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(mycomm);
da.Fill(ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind();
浙公网安备 33010602011771号