sqlCommand.CommandText = "select * from student where studID like @studID and studName like @studName and studSex like @studSex";
 sqlCommand.Parameters.Add("@studID",System.Data.SqlDbType.VarChar,10,"studID");
 sqlCommand.Parameters.Add("@studName",System.Data.SqlDbType.VarChar,10,"studName");
 sqlCommand.Parameters.Add("@studSex",System.Data.SqlDbType.VarChar,2,"studSex");
where sudID like @studID..//@studID啥子意思.
须有识 者启蒙!!

解决方案 »

  1.   

    SQL参数符号sqlCommand.Parameters.Add("@studID",System.Data.SqlDbType.VarChar,10,"studID"); 
    sqlCommand.Parameters.Add("@studName",System.Data.SqlDbType.VarChar,10,"studName"); 
    sqlCommand.Parameters.Add("@studSex",System.Data.SqlDbType.VarChar,2,"studSex"); 红色表示该参数对应的值
    如果你不想用参数,也可以把值直接写进sql中,但那样看起来很乱,而且也不好维护,容易出错
      

  2.   

    最主要,用参数可以防止SQL注入式攻击