⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 securitydb.cs

📁 电子选课系统 电子选课系统电子选课系统电子选课系统
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace Park.Common
{
	/// <summary>
	/// Security 的摘要说明。
	/// </summary>
	public class SecurityDB
	{
		public static bool SetPassword(string userid, string oldpassword, string newpassword)
		{
			SqlConnection myConnection=Utils.GetConnection();

			SqlCommand myCommand = new SqlCommand("Security_Set_Password", myConnection);

			// 
			myCommand.CommandType = CommandType.StoredProcedure;

			// 添加参数
			SqlParameter UserId = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
			UserId.Value = userid;
			myCommand.Parameters.Add(UserId);

			// 添加参数
			SqlParameter OldPassword = new SqlParameter("@OldPassword", SqlDbType.VarChar, 50);
			OldPassword.Value = oldpassword;
			myCommand.Parameters.Add(OldPassword);

			// 添加参数
			SqlParameter NewPassword = new SqlParameter("@Password", SqlDbType.VarChar, 50);
			NewPassword.Value = newpassword;
			myCommand.Parameters.Add(NewPassword);


			// 添加参数
			SqlParameter retval = new SqlParameter("@Return", SqlDbType.Int);
			retval.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(retval);

			// 执行存储过程
			myConnection.Open();

			try
			{
				myCommand.ExecuteNonQuery();
			}
			catch(Exception )
			{
				myCommand.Dispose();
				myConnection.Dispose();
				return false;
			}
				
			myCommand.Dispose();
			myConnection.Dispose();

			return  retval.Value.Equals(1);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -