SqlConnection conn =
new SqlConnection(ConfigurationSettings.AppSettings["sanjia"]);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
string sql = "";
sql = "SELECT COUNT(*) AS users_found2 FROM oauser WHERE (username = '" + TextBox1.Text + "') or (loginname = '" +TextBox2.Text+ "')";
cmd.CommandType = CommandType.Text;
cmd.CommandText = sql;
cmd.Connection = conn;
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
if (reader.GetValue(0).ToString() != "0")
{
Label1.Text = "真实姓名或登录名以存在!";
}
else
{
SqlConnection MyConnection;
SqlCommand MyCommand;
String ConnStr;
MyConnection =new SqlConnection(ConfigurationSettings.AppSettings["sanjia"]);
MyConnection.Open();
if ((SID.Text.Trim()=="")||(TextBox1.Text.Trim()=="")||(TextBox2.Text.Trim()=="")||(TextBox3.Text.Trim()=="")||(TextBox4.Text.Trim()==""))
{
Label1.Text="前五项不能为空!";
}
else if (TextBox1.Text.Trim().Length>=8)
{
Label1.Text="你的用户名太长了!";
}
else if (TextBox2.Text.Trim().Length>=10)
{
Label1.Text="你的登录太长了!";
}
else if (TextBox3.Text.Trim().Length>=13)
{
Label1.Text="你的密码太长了!";
}
else if (TextBox3.Text.Trim().Length<4)
{
Label1.Text="你的密码太短了!";
}
else if (TextBox4.Text.Trim()!=TextBox4.Text.Trim())
{
Label1.Text="你的密码不一致!";
}
else
{
ConnStr="insert into oauser(sid,username,loginname,password,email,call,tel,address,dept,userright,sfkq) VALUES('"+SID.Text+"','"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox5.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+TextBox8.Text+"','"+DropDownList1.SelectedItem.Text+"','"+DropDownList2.SelectedItem.Text+"','"+RadioButtonList1.SelectedItem.Value+"')";
MyCommand=new SqlCommand(ConnStr,MyConnection);
MyCommand.ExecuteNonQuery();
Label1.Text="增加成功!";
}
}
}
}
new SqlConnection(ConfigurationSettings.AppSettings["sanjia"]);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
string sql = "";
sql = "SELECT COUNT(*) AS users_found2 FROM oauser WHERE (username = '" + TextBox1.Text + "') or (loginname = '" +TextBox2.Text+ "')";
cmd.CommandType = CommandType.Text;
cmd.CommandText = sql;
cmd.Connection = conn;
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
if (reader.GetValue(0).ToString() != "0")
{
Label1.Text = "真实姓名或登录名以存在!";
}
else
{
SqlConnection MyConnection;
SqlCommand MyCommand;
String ConnStr;
MyConnection =new SqlConnection(ConfigurationSettings.AppSettings["sanjia"]);
MyConnection.Open();
if ((SID.Text.Trim()=="")||(TextBox1.Text.Trim()=="")||(TextBox2.Text.Trim()=="")||(TextBox3.Text.Trim()=="")||(TextBox4.Text.Trim()==""))
{
Label1.Text="前五项不能为空!";
}
else if (TextBox1.Text.Trim().Length>=8)
{
Label1.Text="你的用户名太长了!";
}
else if (TextBox2.Text.Trim().Length>=10)
{
Label1.Text="你的登录太长了!";
}
else if (TextBox3.Text.Trim().Length>=13)
{
Label1.Text="你的密码太长了!";
}
else if (TextBox3.Text.Trim().Length<4)
{
Label1.Text="你的密码太短了!";
}
else if (TextBox4.Text.Trim()!=TextBox4.Text.Trim())
{
Label1.Text="你的密码不一致!";
}
else
{
ConnStr="insert into oauser(sid,username,loginname,password,email,call,tel,address,dept,userright,sfkq) VALUES('"+SID.Text+"','"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox5.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+TextBox8.Text+"','"+DropDownList1.SelectedItem.Text+"','"+DropDownList2.SelectedItem.Text+"','"+RadioButtonList1.SelectedItem.Value+"')";
MyCommand=new SqlCommand(ConnStr,MyConnection);
MyCommand.ExecuteNonQuery();
Label1.Text="增加成功!";
}
}
}
}
解决方案 »
- [100分求助]服务器偶尔会返回这个错误{在一个非套接字上尝试了一个操作}
- 重大问题,进来帮我下~~~~
- 执行一个绑定操作过程中如何使每个用户返回不用的一个数据
- 对浏览器设置有什么需求吗?为什么我的程序有的浏览器访问有问题,有的没有问题??
- 为什么我的email 发送不出去(实在没分了,谁来帮我看看)
- IIS问题:如何在web程序里具有权限操作IIS?(是在asp.net程序中而不是在winform或console下)
- ###定义公式解析的问题##
- 关于后台编码文件中如何取用户控件的属性值(C#)
- 应该怎样判断页面是否转到另一页呢???
- 一个很简单的问题,如何得到改变后的textbox.text?
- 大家帮帮忙,关于用户输入特殊字符的处理,谈谈高见!!
- 什么是代理类?作用?怎么写?
msg.getMsg("您的编号已存在,请重新确认!")
Exit Sub
End If在“注册”按钮里加上这段代码。