代码请教
SqlConnection1 = new SqlConnection(ConfigurationSettings.AppSettings["aa"]);
SqlCommand1=new SqlCommand("class",SqlConnection1);
SqlCommand1.CommandType=CommandType.StoredProcedure;
SqlCommand1.Parameters.Add("@Id",SqlDbType.BigInt);
SqlCommand1.Parameters["@Id"].Value = MyDataGrid.DataKeys[e.Item.ItemIndex];
什么意思,尤其后两行什么意思???
------解决方案--------------------
(new一个数据库连接)SqlConnection1 = new SqlConnection(ConfigurationSettings.AppSettings["aa"]);
(创建一个数据用于以上连接的sql命令)SqlCommand1=new SqlCommand("class",SqlConnection1);
(这个sql命令是存储过程)SqlCommand1.CommandType=CommandType.StoredProcedure;
(给这个Sql命令指定一个参数和它的类型)SqlCommand1.Parameters.Add("@Id",SqlDbType.BigInt);
(给这个参数赋值)SqlCommand1.Parameters["@Id"].Value = MyDataGrid.DataKeys[e.Item.ItemIndex];