using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = DB.CreateConn();
conn.Open();
string SelUser = "select * from [User]";
OleDbCommand Command = new OleDbCommand(SelUser, conn);
OleDbDataReader Dr = Command.ExecuteReader();
while (Dr.Read())
{
if (this.Name.Text == Dr["UserName"].ToString())
{
Response.Write("该用户名已被注册!");
}
}
Dr.Close();
if (Page.IsValid)
{
string InUser = "insert into User(UserName,UserPwd) values('" + this.Name.Text.ToString() + "','" + this.Pwd.Text.ToString() + "')";
OleDbCommand InCommand = new OleDbCommand(InUser, conn);
try
{
InCommand.ExecuteNonQuery();
Response.Write("注册成功");
}
catch (Exception exp)
{
Response.Write(exp.Message);
}
}
else
{
Response.Write("未通过验证!");
}
conn.Close();
}
}
insert into 语句为何错误,还请指点