c# - Stored procedure/query two variable comparison -


i have created stored procedure sql server 2014.

there 2 parameters: name user name , hash password md5 hash. check in database if md5 hashes equal (first hash program , second 1 stored in database).

if run query (not stored procedure) in database (or in program using commandtype.text) - works , user being selected, when run exact thing using stored procedures, sqlreader in c# has no elements returned, means conditions during variable comparison not met.

maybe doing wrong?

i have 10 other stored procedures reading or/and writing database, works except one.

here procedure:

create procedure gethash    @name nvarchar(50),    @hash nvarchar(200) begin     set nocount on;      select orders.orderid, employee.name, employee.surname     orders      left join employee on orders.orderid = employee.id     batchname = '@name' , productcode = '@hash' end go 

code part:

    public boolean verifypassword(string name, string password)     {         var paramslist = new list<sqlparameter> { new sqlparameter("@name", name), new sqlparameter("@hash", getmd5hash(password)) };          const string procedurename = "gethash";         var activeuser = new dbcontroller().getfromdatabase(procedurename, "login", "ejl15_db", paramslist).tolist();         return activeuser.count > 0;     } 

and database controller

    private void setcommandproperties(string procedurename, ienumerable<sqlparameter> paramslist)     {         this.sqlcommand.commandtext = procedurename;         this.sqlcommand.commandtype = commandtype.storedprocedure;         foreach (var curparam in paramslist)             this.sqlcommand.parameters.add(curparam);          this.sqlcommand.commandtimeout = 15;     } 

you don't need quote parameters in stored procedure. instead:

create procedure gethash     @name nvarchar(50),     @hash nvarchar(200)  begin     set nocount on;      select orders.orderid,             employee.name,             employee.surname     orders      left join employee         on orders.orderid=employee.id     batchname = @name     , productcode = @hash end 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -