[Quote=引用 9 楼 thebesttome 的回复:]
if(查询数据库中是否有数据) 若有 select count(1) from a where
{
return false
}
else
{
插入数据
}
[/Quote]
StringBuilder SB = new StringBuilder();
string sql = string.Format("select * from qqq where Name='{0}'",Name);
SqlCommand comm = new SqlCommand(sql,conn);
SqlDataReader da = comm.ExecuteReader();
if(da.Read()){
if (Name.Equals(da["Name"].ToString()))
{
Console.WriteLine("用户名已注册!!!");
}
}
else
{
SB.AppendFormat("insert into qqq values('{0}','{1}')", Name, Pwd);
SqlCommand co = new SqlCommand(Convert.ToString(SB), conn);