Error on Parameter C# SQL -


i need verify parameter rgp, peixe, data_registro method return true. on peixe parameter giving error:

expects 'peixe' parameter, not provided.

peixe varchar type on sql, rgp int type , data_registro date type.

 public bool search_rgp_cadastro(int param_rgp, string param_date, string param_peixe)     {         sqldatareader objreader;         sqlcommand objcmd = null;          vsql = "select [rgp], [peixe], [peso], [quantidade], [data_registro] cadastro rgp = @rgp , peixe = @peixe , data_registro = @data_registro";          if (this.conectar())         {             try             {                 datetime dtparam = datetime.parse(param_date);                  objcmd = new sqlcommand(vsql, objcon);                  objcmd.parameters.add(new sqlparameter("@rgp", param_rgp));                 objcmd.parameters.add(new sqlparameter("@peixe", param_peixe));                 objcmd.parameters.add(new sqlparameter("@data_registro", dtparam));                  objreader = objcmd.executereader();                  if (objreader.read())                 {                     valor.retorna_rgp = objreader.getint32(0);                     valor.retorna_nome_peixe = objreader.getstring(1);                     valor.retorna_peso = objreader.getdouble(2);                     valor.retorna_quantidade = objreader.getint32(3);                     valor.retorna_date_time = objreader.getdatetime(4);                 }                 return true;             }             catch             {                 throw;             }                         {                 this.desconectar();             }           }         else             return false;       } 

i'd wrap param_peixe in single quotes, this:

objcmd.parameters.add(new sqlparameter("@peixe", "'" + param_peixe + "'")); 

it wouldn't first time i've seen sql reject use of string varchar.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -