必须声明标量变量 10
我明明已经声明了变量,SQLserver2005的====================================DECLARE@csIdINT,@maxsINT...
我明明已经声明了变量, SQL server 2005的
====================================
DECLARE @csId INT , @maxs INT ;
DECLARE my_cursor CURSOR FOR
SELECT a.CourseId,a.CountLimits FROM dbo.T_ElectiveCourse a WHERE a.SemesterId=5;
OPEN my_cursor
FETCH NEXT FROM my_cursor INTO @csId , @maxs ;
WHILE (@@FETCH_STATUS = 0)
BEGIN
--PRINT @csId ;
FETCH NEXT FROM my_cursor INTO @csId , @maxs ;
END;
CLOSE my_cursor;
DEALLOCATE my_cursor;
=报错如下:============================
[SQL]
OPEN my_cursor
FETCH NEXT FROM my_cursor INTO @csId , @maxs
[Err] 42000 - [SQL Server]必须声明标量变量 "@csId"。 展开
====================================
DECLARE @csId INT , @maxs INT ;
DECLARE my_cursor CURSOR FOR
SELECT a.CourseId,a.CountLimits FROM dbo.T_ElectiveCourse a WHERE a.SemesterId=5;
OPEN my_cursor
FETCH NEXT FROM my_cursor INTO @csId , @maxs ;
WHILE (@@FETCH_STATUS = 0)
BEGIN
--PRINT @csId ;
FETCH NEXT FROM my_cursor INTO @csId , @maxs ;
END;
CLOSE my_cursor;
DEALLOCATE my_cursor;
=报错如下:============================
[SQL]
OPEN my_cursor
FETCH NEXT FROM my_cursor INTO @csId , @maxs
[Err] 42000 - [SQL Server]必须声明标量变量 "@csId"。 展开
2个回答
展开全部
很明显的错误
string t_sql = "select 管理员,密码 from yonghu where 管理员=@username and 密码=@oldpass";
cmd = new SqlCommand(t_sql, conn);
try
{
conn.Open();
SqlParameter pu = new SqlParameter("@username", SqlDbType.VarChar, 200);
SqlParameter ppassword = new SqlParameter("@newpass", SqlDbType.VarChar, 200);
cmd.Parameters.Add(pu);
cmd.Parameters.Add(ppassword);
dr = cmd.ExecuteReader();
dr.Read();
你的sql语句里面写的参数是 密码=@oldpass";
你这里new的是@newpass ,没提供@oldpass
SqlParameter ppassword = new SqlParameter("@newpass", SqlDbType.VarChar, 200);
string t_sql = "select 管理员,密码 from yonghu where 管理员=@username and 密码=@oldpass";
cmd = new SqlCommand(t_sql, conn);
try
{
conn.Open();
SqlParameter pu = new SqlParameter("@username", SqlDbType.VarChar, 200);
SqlParameter ppassword = new SqlParameter("@newpass", SqlDbType.VarChar, 200);
cmd.Parameters.Add(pu);
cmd.Parameters.Add(ppassword);
dr = cmd.ExecuteReader();
dr.Read();
你的sql语句里面写的参数是 密码=@oldpass";
你这里new的是@newpass ,没提供@oldpass
SqlParameter ppassword = new SqlParameter("@newpass", SqlDbType.VarChar, 200);
追问
你说得跟我的代码有毛关系啊!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询