我写的这个注册页面对吗?一些一看网上写的一些是自己写的.还有为什么if  (Convert.ToInt32(sqll) > 0) 会说输入字符串的格式不正确?private void Button1_Click(object sender, System.EventArgs e)
{  String sqlconn="Data Source=localhost;uid=sa;pwd=;Initial Catalog=bbs;Trusted_Connection=no";
SqlConnection myConnection=new SqlConnection(sqlconn);myConnection.Open();string sqll="select count(TB1) as TB1 from TB where TB1='"+this.TB1.Text.ToString()+"'
if  (Convert.ToInt32(sqll) > 0) 
{   
Response.Redirect("zc1.aspx");
}   
else   
{   
string sql="insert into TB(TB1,TB2) values( '"+TB1.Text+"', '"+TB2.Text+"')   ";
SqlCommand myCommand=new SqlCommand(sql,myConnection);
myCommand.ExecuteNonQuery();
myConnection.Close();              
Response.Redirect("WebForm2.aspx");
}

}

解决方案 »

  1.   

    if  (Convert.ToInt32(sqll) >  0)  
    这个sqll你好像是字符串..你怎么转换INT32类型?????
      

  2.   


    String sqlconn="Data Source=localhost;uid=sa;pwd=;Initial Catalog=bbs;Trusted_Connection=no"; 
    SqlConnection myConnection=new SqlConnection(sqlconn); 
    myConnection.Open();
    string sqll="select count(TB1) as TB1 from TB where TB1='"+this.TB1.Text.ToString()+"'" ;
    SqlCommand myCommand = new SqlCommand(sqll, myConnection); 
    if  (Convert.ToInt32( myCommand.ExecuteScalar()) >  0)  
    {    
    Response.Redirect("zc1.aspx"); 
    }    
    else    
    {    
    string sql="insert into TB(TB1,TB2) values( '"+TB1.Text+"', '"+TB2.Text+"')   "; 
    myCommand=new SqlCommand(sql,myConnection); 
    myCommand.ExecuteNonQuery(); 
    myConnection.Close();               
    Response.Redirect("WebForm2.aspx"); 
      

  3.   

    你得先让用户..先注册进去..才可以判断有没有注册成功..你写的只是判断你的SQL语句的长度是否大于0,,而且还少了length故而说你字符串不正确;先要搞清楚.步骤...