问题描述
StringstrConnection=ConfigurationSettings.AppSettings["ConnectionString"];//通过调试strconnection有显示连接信息.SqlConnectioncn=newSqlConnection(strConnection);SqlCommandcm=newSqlCommand("updateu",cn);//updateu用快速监控显示:当前上下文中不存在名称“updateu”cm.CommandType=CommandType.StoredProcedure;cm.Connection.Open();GuiduserID;stringuserLogName,username,sex,phone,mobilephone;但是存储过程是有的:createProcedure[dbo].[updateu]@userLogNamenvarchar(30),@userNamevarchar(20),@Sexnvarchar(4),@Phonenvarchar(18),@mobilephonenvarchar(12),@userIDuniqueidentifierASUpdateusersSetuserLogName=@userLogName,userName=@userName,Sex=@Sex,Phone=@Phone,mobilephone=@mobilephoneWhereuserID=@userIDGO
解决方案
解决方案二:
先open再newsqlcommand
解决方案三:
SqlCommandcm=newSqlCommand("dbo.updateu",cn);
解决方案四:
我都快疯了:这是调试的一些反馈StringstrConnection=ConfigurationSettings.AppSettings["ConnectionString"];SqlConnectioncn=newSqlConnection(strConnection);//监控:cn={System.Data.SqlClient.SqlConnection}SqlCommandcm=newSqlCommand("dbo.updateu",cn);//监控:cm=System.Data.SqlClient.SqlCommand}cm.CommandType=CommandType.StoredProcedure;cm.Connection.Open();GuiduserID;//userID=00000000-0000-0000-0000-000000000000}stringuserLogName,username,sex,phone,mobilephone;//这些都是nulluserID=newGuid(GridView1.Rows[e.RowIndex].Cells[0].Controls[0].ToString());userLogName=((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
解决方案五:
SqlConnectionconn=newSqlConnection(ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString);SqlCommandcmd=newSqlCommand();cmd.CommandText="northwind_OrdersPaged";cmd.Parameters.Add(newSqlParameter("@PageIndex",SqlDbType.Int));cmd.Parameters["@PageIndex"].Value=1;cmd.Parameters.Add(newSqlParameter("@PageSize",SqlDbType.Int));cmd.Parameters["@PageSize"].Value=10;cmd.CommandType=CommandType.StoredProcedure;cmd.Connection=conn;cmd.Connection.Open();SqlDataReaderdr=cmd.ExecuteReader();
解决方案六:
看看书或是网上找到例子你写的东西有点乱你明白什么意思么???
解决方案七:
你没运行阿cmd.excutenoquery'具体不记得了,但似乎你要执行一下