c# - sqlParameterCollection error -


i have definiton of procedure

public int add_nastavenie(out int typnastav, int nastavid, string hod) {     resetparameters();     cmd.commandtext = "add_nastav";     cmd.commandtype = commandtype.storedprocedure;      sqlparameter sqlparameter;      var sqlparameterout = new sqlparameter("@typnastav", sqldbtype.int);     sqlparameterout.direction = parameterdirection.output;       sqlparameter = new sqlparameter("@nastavenieid", sqldbtype.int);     sqlparameter.direction = parameterdirection.input;     sqlparameter.value = nastavid;     cmd.parameters.add(sqlparameter);      sqlparameter = new sqlparameter("@hodnota", sqldbtype.nvarchar, 100);     sqlparameter.direction = parameterdirection.input;     sqlparameter.value = hod;     cmd.parameters.add(sqlparameter);      var sqlparameterret = new sqlparameter("retvalue", sqldbtype.int);     sqlparameterret.direction = parameterdirection.returnvalue;      cmd.executenonquery();     typnastav = (int)sqlparameterout.value;     return (int)cmd.parameters["retvalue"].value;  } 

i call procedure :

 dataconnector.add_nastavenie(out typnastav,nastavid,hod);  

it's show error :

sql parameter parametername 'retvalue' not contained sqlparametercollection

how can fix ?

you getting because haven't added return parameter command. missed this

cmd.parameters.add(sqlparameterret ); 

before

cmd.executenonquery(); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -