c# - Acess SQL query missing more required parameters -


in web project, i'm trying execute following query:

select itemname name,        itempicture picture,        itemheromodif assistance,        itemtroopmodif charisma,        herbcost herbs,        gemcost gems item itemid = @value0 

with breakpoints, can see attached @value0 value, 2.

despite this, following error:

no value given 1 or more required parameters.

i understood error generated due bad sql syntax. there wrong did?

edit:

attachment code:

var madeforcommand = "select itemname name,itempicture [picture],itemheromodif assistance,itemtroopmodif charisma, herbcost herbs, gemcost gems item ";         oledbcommand command = new oledbcommand();         (int ii = 0; ii < items.count; ii++)// items list of items ids want query.         {             madeforcommand += "itemid =@value"+ii+" or ";            }         madeforcommand = madeforcommand.substring(0, madeforcommand.length - 4); // making sure trim final or; in case shown, it's 1 item, there none @ all. 

and later on:

oledbcommand foroperations = new oledbcommand(madeforcommand, _dbconnection); //_dbconnection connection database, seems work pretty well. (int ii = 0; ii < items.count; ii++)          {             string attach = "@value" + ii;             command.parameters.addwithvalue(attach, items[ii].id);         } 

i'm pretty sure items[ii].id fine, breakpoints show equals 2 , attachment goes well.

edit 2: i've editted code krish , hans advised me, , following query without attachments: select itemname [name],itempicture picture,itemheromodif assistance,itemtroopmodif charisma, herbcost herbs, gemcost gems [item] (itemid in (2));. still same error, if changes anything.

edit 3: executing query in access asks me give value parameter "itempicture"... odd; itempicture column, isn't it?

name, item, , picture problem words in access queries. enclose them in square brackets:

select itemname [name], itempicture [picture], itemheromodif assistance, itemtroopmodif charisma, herbcost herbs, gemcost gems [item] itemid in (2); 

since bracketing names still gave missing parameter complaint, asked test query in access' query designer. in context, access presents parameter input box includes word access interprets parameter.

you reported access thinks itempicture parameter. inspecting table in access design view, discovered actual field name itemimageurl.

select itemname [name], itemimageurl [picture], itemheromodif assistance, itemtroopmodif charisma, herbcost herbs, gemcost gems [item] itemid in (2); 

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 -