日期:2014-05-17 浏览次数:20895 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace Login.DAL
{
public class UserDAO
{
public Login.Model.UserInfo SelectUser(string userName ,string passWord)
{
using(SqlConnection conn = new SqlConnection(DbUtil.connString))
{
conn.Open();
string tsqlstring="SELECT ID,UserName,PassWord,Email FROM Users WHERE UserName='"+LoginUI.LoginForm.txtUserName.Text.Trim()+"' AND PassWord='"+LoginUI.LoginForm.txtPassWord.Text+"' ";
SqlCommand cmd = new SqlCommand(conn, tsqlstring);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Users");
Login.Model.UserInfo uinfo = null;
uinfo.IDM = ds.Tables[0].Rows[0][0].ToString();
uinfo.UserNameM = ds.Tables[0].Rows[0][1].ToString();
uinfo.PassWordM = ds.Tables[0].Rows[0][2].ToString();
if (ds.Tables[0].Rows[0][3].ToString() != null)
{
uinfo.EmailM = ds.Tables[0].Rows[0][3].ToString();
}
return uinfo;
}
}
}
}