; m_strPassword = myReader["password"].ToString() ;
m_strEmail = myReader["Email"].ToString() ;
m_strHomepage = myReader["Homepage"].ToString() ;
m_strSignature = myReader["Signature"].ToString() ;
bExists = true ;
}
else
{
bExists = false ;
}
myReader.Close() ;
myConn.Close() ;
}
catch(SQLException e) //如果出现异常
{
throw(new Exception("数据库异常:" + e.Message)) ;
}
//返回结果
return bExists ;
}
//重载,根据用户ID查找用户
public bool GetUser(int a_intUserID)
{
bool bExists = false ;
MyConnection myConn = new MyConnection() ;
try
{
myConn.Open() ;
SQLCommand myCommand = new SQLCommand() ;
myCommand.ActiveConnection = myConn ;
myCommand.CommandText = "select * from BBSUser where id=" +
a_intUserID.ToString() ;
SQLDataReader myReader ;
myCommand.Execute(out myReader) ;
if (myReader.Read())
{
m_intID = (int)myReader["ID"] ;
m_strUserName = myReader["UserName"].ToString() ;
m_strPassword = myReader["password"].ToString() ;
m_strEmail = myReader["Email"].ToString() ;
m_strHomepage = myReader["Homepage"].ToString() ;
m_strSignature = myReader["Signature"].ToString() ;
bExists = true ;
}
else
{
bExists = false ;
}
myReader.Close() ;
myConn.Close() ;
}
catch(SQLException e) //如果出现异常
{
throw(new Exception("数据库异常:" + e.Message)) ;
}
//返回结果
return bExists ;
}
//新建用户
public void CreateUser(BBSUser.CreateType a_enumCreateType ,string
a_strUserName ,
string a_strPassword ,
string a_strEmail ,
string a_strHomepage ,
string a_strSignature)
{
//监测参数有效性
if (a_strUserName.IndexOf("'") != -1 || a_strPassword.IndexOf("'")
!= -1
|| a_strEmail.IndexOf("'") != -1 ||
a_strHomepage.IndexOf("'") != -1
|| a_strSignature.IndexOf("'") != -1)
{
throw(new Exception("包含非法字符")) ;
}
try
{
MyOwnClass.MyConnection myConn = new MyConnection() ;
SQLCommand myCmd = new SQLCommand() ;
//判断是新建用户还是修改用户资料
&
m_strEmail = myReader["Email"].ToString() ;
m_strHomepage = myReader["Homepage"].ToString() ;
m_strSignature = myReader["Signature"].ToString() ;
bExists = true ;
}
else
{
bExists = false ;
}
myReader.Close() ;
myConn.Close() ;
}
catch(SQLException e) //如果出现异常
{
throw(new Exception("数据库异常:" + e.Message)) ;
}
//返回结果
return bExists ;
}
//重载,根据用户ID查找用户
public bool GetUser(int a_intUserID)
{
bool bExists = false ;
MyConnection myConn = new MyConnection() ;
try
{
myConn.Open() ;
SQLCommand myCommand = new SQLCommand() ;
myCommand.ActiveConnection = myConn ;
myCommand.CommandText = "select * from BBSUser where id=" +
a_intUserID.ToString() ;
SQLDataReader myReader ;
myCommand.Execute(out myReader) ;
if (myReader.Read())
{
m_intID = (int)myReader["ID"] ;
m_strUserName = myReader["UserName"].ToString() ;
m_strPassword = myReader["password"].ToString() ;
m_strEmail = myReader["Email"].ToString() ;
m_strHomepage = myReader["Homepage"].ToString() ;
m_strSignature = myReader["Signature"].ToString() ;
bExists = true ;
}
else
{
bExists = false ;
}
myReader.Close() ;
myConn.Close() ;
}
catch(SQLException e) //如果出现异常
{
throw(new Exception("数据库异常:" + e.Message)) ;
}
//返回结果
return bExists ;
}
//新建用户
public void CreateUser(BBSUser.CreateType a_enumCreateType ,string
a_strUserName ,
string a_strPassword ,
string a_strEmail ,
string a_strHomepage ,
string a_strSignature)
{
//监测参数有效性
if (a_strUserName.IndexOf("'") != -1 || a_strPassword.IndexOf("'")
!= -1
|| a_strEmail.IndexOf("'") != -1 ||
a_strHomepage.IndexOf("'") != -1
|| a_strSignature.IndexOf("'") != -1)
{
throw(new Exception("包含非法字符")) ;
}
try
{
MyOwnClass.MyConnection myConn = new MyConnection() ;
SQLCommand myCmd = new SQLCommand() ;
//判断是新建用户还是修改用户资料
&