1方法一:
 2private 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方法二:
35private 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