首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

代码请问

2012-03-08 
代码请教SqlConnection1 new SqlConnection(ConfigurationSettings.AppSettings[aa])SqlCommand1new

代码请教
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]; 

热点排行