Retrieving data from SQL Server with a stored procedure with ASP.net and c# -


i have form , want retrieve data sql table , show in form's fields depending on ?id enter in url, error:

procedure or function 'getappform' expects parameter '@id', not supplied.

note: getappform stored procedure.

here's code, please me:

try {     if (string.isnullorempty(request.querystring["id"]))     {         sqlconn.open();          using (sqlcommand cmd = new sqlcommand("getappform", sqlconn))         {             cmd.commandtype = commandtype.storedprocedure;              sqlparameter id = cmd.parameters.add("@id", sqldbtype.int);                                 id.direction = parameterdirection.input;             id.value = request.querystring["id"];              sqldatareader datareader = cmd.executereader(commandbehavior.closeconnection);              while (datareader.read())             {                 ownerfield.text = datareader["owner"].tostring();                 odbooknofield.text = datareader["od"].tostring();                 pdlocfield.text = datareader["pd"].tostring();                 statementnofield.text = datareader["statmnt"].tostring();                 applicationnofield.text = datareader["appno"].tostring();                 appdatefield.text = datareader["appdate"].tostring();                 areafield.text = datareader["area"].tostring();                 areanofield.text = datareader["areano"].tostring();                 blocknofield.text = datareader["blockno"].tostring();                 streetnofield.text = datareader["streetno"].tostring();             }         }     } } catch (exception ex) {     httpcontext.current.response.write("no connection!!"); } {     sqlconn.close(); } 

change

if (string.isnullorempty(request.querystring["id"])) 

to

if (!string.isnullorempty(request.querystring["id"])) 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -