接收URL传过来的id值,然后在存储过程里使用它. 现在出现错误:未将对象引用设置到对象的实例.
恳请大佬们帮我看看哪错了?
protected void Page_Load()
{
SqlConnection SqlConnection1 = new SqlConnection("..");
string sid = Request.QueryString["id"].ToString();
SqlCommand cmd = new SqlCommand("showrestore", SqlConnection1);
SqlConnection1.Open();
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("@id", SqlDbType.Int);
p1.Value = Convert.ToInt32(sid);
cmd.Parameters.Add(p1);
cmd.ExecuteNonQuery();
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter("showrestore", SqlConnection1);
DataSet DataSet1 = new DataSet();
SqlDataAdapter1.Fill(DataSet1);
DataGrid1.DataSource = DataSet1;
DataGrid1.DataBind();
}
请多指教..
[此贴子已经被作者于2007-8-11 10:21:53编辑过]