1
方法一:
2
private void btnNext_Click(object sender, System.EventArgs e)
3
{
4
if(Page.IsValid)
5
{
6
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("txl.aspx");
7
cn=new OleDbConnection(strConn);
8
strSQL="select count(u_id) from userinfo where u_account='"+txtAccount.Text.ToString()+"'";
9
10
cn.Open();
11
cmd=new OleDbCommand(strSQL,cn);
12
13
int flag=(int)cmd.ExecuteScalar();
14
15
if(flag>0)
16
17
{
18
lblStep2.Text="您输入的用户名已经存在,请您选择一个其他的名字!";
19
cn.Close();
20
21
//txtAccount.Text="";
22
}
23
else
24
{
25
cn.Close();
26
lblPwd.Text=txtUpwd.Text.ToString();
27
28
}
29
}
30
}
31
32
33
34
方法二:
35
private void btnNext_Click(object sender, System.EventArgs e)
36
{
37
if(Page.IsValid)
38
{
39
40
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("txl.aspx");
41
cn=new OleDbConnection(strConn);
42
strSQL="select u_id from userinfo where u_account='"+txtAccount.Text.ToString()+"'";
43
44
dr=cmd.ExecuteReader();
45
if(dr.Read())
46
{
47
lblStep2.Text="您输入的用户名已经存在,请您选择一个其他的名字!";
48
cn.Close();
49
50
//txtAccount.Text="";
51
}
52
else
53
{
54
cn.Close();
55
lblPwd.Text=txtUpwd.Text.ToString();
56
57
58
}
59
}
60
}
61
62
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
浙公网安备 33010602011771号