Passing SqlParameter in webmethod asp.net -
i trying create web service execute stored procedure. , web method calling in code execute stored procedure. web method -
[webmethod(description = des_executeparamerizedselectcommand)] public datatable executeparamerizedselectcommand(string commandname, commandtype cmdtype, sqlparameter[] param) { datatable table = new datatable(); using (sqlconnection con = new sqlconnection(connectionstring())) { using (sqlcommand cmd = con.createcommand()) { cmd.commandtype = cmdtype; cmd.commandtext = commandname; cmd.parameters.addrange(param); try { if (con.state != connectionstate.open) { con.open(); } using (sqldataadapter da = new sqldataadapter(cmd)) { da.fill(table); } } catch { throw; } } } return table; }
now code in data access layer - when trying call web method, throwing compile time error.
error 2 argument 2: cannot convert 'system.data.commandtype' 'dal.sqldbhelper.commandtype' error 3 argument 3: cannot convert 'system.data.sqlclient.sqlparameter[]' 'dal.sqldbhelper.sqlparameter[]'
my code call webmethod -
sqldbhelper.odcdbhelper mysqldbhelper = new sqldbhelper.odcdbhelper(); public login getuserroles(string _idsid) { login login = null; sqlparameter[] parameters = new sqlparameter[] { new sqlparameter("@username", _idsid) }; //lets list of employees in datataable using (datatable table = mysqldbhelper.executeparamerizedselectcommand("getuserrole", commandtype.storedprocedure, parameters))
can please tell me someone, wrong??
thanks in advance gulrej
try this
dal.sqldbhelper.sqlparameter[] parameters = new dal.sqldbhelper.sqlparameter[]//change here { sqlparameter("@username", _idsid) }; //lets list of employees in datataable using (datatable table = mysqldbhelper.executeparamerizedselectcommand("getuserrole", dal.sqldbhelper.commandtype.storedprocedure, parameters))
Comments
Post a Comment