在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
con.Open(); //指定存储过程的执行时的参数 ************************************************************************************************* 执行存储过程的返回值:
1 /// <summary>
2 /// 校验用户 3 /// </summary> 4 /// <param name="user">用户信息</param> 5 /// <returns></returns> 6 public static int VerifyUser(clsUser user) 7 { 8 int iRet; 9 string sql = String.Format("EXECUTE VerifyUser @myVerifyReader OUTPUT,'{0}','{1}'",user.username,user.password); //执行的T-SQL串 10 SqlCommand scmd = new SqlCommand(sql, conn); 11 scmd.Parameters.Add(new SqlParameter("@myVerifyReader",SqlDbType.Int)); 12 scmd.Parameters["@myVerifyReader"].Direction = ParameterDirection.Output; 13 // 14 15 DBOpen(conn); 16 //在返回值上有问题 17 scmd.ExecuteNonQuery(); 18 iRet = (int)scmd.Parameters["@myVerifyReader"].Value; 19 DBClose(conn); 20 return iRet; 21 }
------------------------------
/* * VerifyUser 存储过程 * 用途:验证用户登陆 */ CREATE PROCEDURE VerifyUser ( @myVerifyReader int OUTPUT, --返回结果 @username varchar(50), --用户名 @userpassword varchar(50) --用户密码 ) AS IF EXISTS(SELECT [id] FROM [Users] WHERE username = @username AND userpassword = @userpassword) SET @myVerifyReader = 0 --通过验证 ELSE IF EXISTS(SELECT [id] FROM [Users] WHERE username = @username) SET @myVerifyReader = 1 --用户存在,密码不正确 ELSE SET @myVerifyReader = 2 --用户不存在 RETURN isnull(@myVerifyReader,3) ------------------------------------------------- GO |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论