MySQL Stored Proc and c# data reader column wrong values -


i have situation in such way variable value has returned based on multiple condition. set passed parameter value. below algo,

    create proc checkflag (ppleid int,  pflag bit, loginid int)     begin declare vflag bit; declare vhasrights bit; declare vislocked bit; declare vlockeduid int;  set vflag=pflag;  // assign passed param   if (vflag = 0)       select id, name,vflag 'iseditable'       peopletable       id=ppleid; else -- algo check whether loginid has rights edit           if (vhasrights = 1)                            -- sql statements check whether record not write locked visalreadylocked                   if (visalreadylocked = 1)                                           --- sql statements check whether locked user login user in vlockeduid                      if (vlockeduid = ploginid)                                             set vflag =1;                     else                         set vflag=0;                     end if;                   else                       set vflag=0;                   end if;       select id, name,vflag 'iseditable'       peopletable       id=ppleid;    end if; end; 

a. sp. call withing sqleditor call checkflag(values.....); returns appropriate value

b. sp. call c#

internal void readppl() {      bool initflag=<flag based on client end condition>;      . code creating connection , command of type storedproc      . 

mysqlparameter prm=new parameter("pflag", initflag);

    .     .     .  cmd.parameter(prm)     using (mysqldatareader rdr=cmd.executereader())    {       if (rdr.hasrows())      {        rdr.read(); 

**bool iswritable=convert.toboolean(convert.toint32(rdr["iseditable"])); // line returns value passed parameter not based on conditions in db , params **

     } 

any appreciated.

thanks in advance.

got problem solved.

call proc(@flag...)

resulted @flag other 0. else condition executed.

mysqlparameter prm=new(....,value=initvalue);

considered intivalue 0 hence, first if condition in stored proc. executed every time.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -