www.pudn.com > xiaoyuanwangzhan.rar > db.cs
using System;
using System.Data.SqlClient;
namespace newsystem
{
///
/// db 的摘要说明。
///
public class db
{
public db()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static SqlConnection createcon()
{
return new SqlConnection("server=.;database=web;uid=sa;pwd=911;");
}
public static bool jugejibie(string userName)
{
SqlConnection con=db.createcon();
con.Open();
SqlCommand cmd=new SqlCommand("select jbid from bbs_register where username='"+userName+"'",con);
int jbid=Convert.ToInt32(cmd.ExecuteScalar());
if(jbid==1)
{
return true;
}
else
{
return false;
}
}
public static bool jugelogin(string userName)
{
SqlConnection con=db.createcon();
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from bbs_register where username='"+userName+"'",con);
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
return false;
}
else
{
return true;
}
}
// public static bool jugeregister(string registerName)
// {
// SqlConnection con=db.createcon();
// con.Open();
// SqlCommand cmd=new SqlCommand("select count(*) from bbs_register where username='"+registerName+"'",con);
// int count=Convert.ToInt32(cmd.ExecuteScalar());
// if(count>0)
// {
// return true;
// }
// else
// {
// return false;
// }
// con.Close();
// }
public static bool jugeregister(string registerName)
{
SqlConnection con=db.createcon();
con.Open();
SqlCommand cmd=new SqlCommand("select username from bbs_register where username='"+registerName+"'",con);
SqlDataReader sdr=cmd.ExecuteReader();
if(sdr.Read())
{
return true;
}
else
{
return false;
}
sdr.Close();
con.Close();
}
}
}