private bool Is_Exist()
{string Constring = "Provider=SQLOLEDBData Source=.Integrated Security=SSPIInitial Catalog=shopingdb"
OleDbConnection conn = new OleDbConnection(Constring)
string sql = "select * from users where userName='"
sql += txb_name.Text.Trim() + "'"
OleDbCommand cmd = new OleDbCommand(sql, conn)
OleDbDataReader dr
conn.Open()
dr = cmd.ExecuteReader()
if (dr.Read())
{
txb_name.Text = ""
return true
}
else
return false
}
再在button中写代码
protected void LinkButton8_Click(object sender, EventArgs e)
{
if(!Is_Exist())
{
//不存在该用户,可注册
}
else//存在返回
{
}
}
if user="" thenresponse.write "<SCRIPT language=JavaScript>alert('用户名不能为空 或 输入字符非法!')"
response.write "this.location.href='vbscript:history.back()'</SCRIPT>"
response.end
end if
if password="" then
response.write "<SCRIPT language=JavaScript>alert('密码不能为空 或 输入字符非法!')"
response.write "this.location.href='vbscript:history.back()'</SCRIPT>"
response.end
end if。。。。
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)