——此文章摘自《ASPNET +SQL Server网络应用系统开发案例精解》定价¥特价¥ 详细>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave> ()前面调用了ST_User类的ST_Login()和ST_GetUserInfo()方法其中ST_Login()方法用来验证用户输入的用户名和密码是否正确即从数据库中查询有没有与用户输入的数据相同的数据如果有则返回True说明用户已存在 public bool ST_Login() { //根据用户名密码创建查询用户ID的sql语句 ST_strSQL = Select ST_Id from ST_UserInfo Where ST_Name= + thisST_Name + + And ST_Password= + ST_FunctionsST_Encrypt(thisST_Password) +; try { ST_ExecuteSqlValue(ST_strSQL); return true; } catch { return false; } } ST_GetUserInfo()用来根据用户名创建查询用户信息 public bool ST_GetUserInfo() { //根据用户名创建查询用户信息的sql语句 ST_strSQL = Select * from ST_UserInfo Where ST_Name= + thisST_Name + ; SqlConnection ST_myCn = new SqlConnection(ST_strConn); //打开连接 ST_myCnOpen(); SqlCommand ST_myCmd = new SqlCommand(ST_strSQLST_myCn); try { ST_myCmdExecuteNonQuery(); SqlDataReader reader = ST_myCmdExecuteReader(); if(readerRead()) { //获取用户ID thisST_ID = readerGetInt(); //获取用户邮箱 thisST_Mail = readerGetString(); return true; } else { return false; } } catch(SystemDataSqlClientSqlException e) { throw new Exception(eMessage); } finally right>[http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [] [http://developcsaicn/dotnet_ASP/htm>] |