用c#做一个简单注册页面

来源:百度知道 编辑:UC知道 时间:2024/06/08 20:19:08

string ss = "select count(*) from oauser where username='" + TextBox2.Text + "'";//查看用户名是否被占用
SqlCommand comm = new SqlCommand(ss, myconn);
int value = (int)comm.ExecuteScalar();
if (value == 0)//用户名未被占用
{
string str = "insert oauser VALUES('" + TextBox2.Text + "','" + TextBox3.Text + "','" + "0" + "','" + TextBox1.Text + "')";//添加新用户
SqlCommand mycomm = new SqlCommand(str, myconn);
mycomm.ExecuteNonQuery();
Response.AddHeader("refresh","0;url=Default.aspx");//注册成功,进入登录界面
Response.Write("<script language=javascript>alert('注册成功!!!')</script>");
}