c# - No value given for required parameters, with value -


i'm working in c#/asp.net on web app. part of app, want connect ms-access database, , values dataset.

for reason, error in title when filling dataset dataadaptor- despite this, when use breakpoints, can see command follows: select ..... itemid = @value0 (if need parameters, ask them , i`ll copy whole thing).

i can see @value0 has value 2 breakpoints, , assured it's value in query.

my question is, how happen? if value in query filled, missing?

edit: full query: select itemname name,itempicture picture,itemheromodif assistance,itemtroopmodif charisma, herbcost herbs, gemcost gems item itemid = @value0"

full building code (generating query each user requires different amount of items, 1 has single item, i've used test):

static public dataset getusershopitemds(string username,list<shopitem> items) { string madeforcommand = "select itemname name,itempicture picture,itemheromodif assistance,itemtroopmodif charisma, herbcost herbs, gemcost gems item itemid = ";         int count = 0;         foreach (shopitem item in items)         {             madeforcommand += "@value"+count+" or ";             count++;         }         madeforcommand = madeforcommand.substring(0, madeforcommand.length - 3);         oledbcommand command = generateconnection(madeforcommand);         (int ii = 0; ii < items.count; ii++)         {             command.parameters.addwithvalue("@value" + ii, items[ii].id);         }         var freestyleadaptor = new oledbdataadapter();         freestyleadaptor.selectcommand = command;         dataset items = new dataset();         freestyleadaptor.fill(items);//the error thrown here.         return items;     } 

edit 2: - shopitem class:

public class shopitem {     //irrelevant parameters,     public int id // whenever user logs in, create list of items, , attach each 1 it's id database. send list parameter function.     {         get;         private set;     }     public shopitem(int id)     {         this.id = id;     }     public shopitem() { }     // more constructors. } 

here's code should use:

        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++)         {             madeforcommand += "itemid = ?  or ";             command.parameters.addwithvalue("value" + ii, items[ii].id);         }          madeforcommand = madeforcommand.substring(0, madeforcommand.length - 3); 

in ms access parameters passed using ? , have provided in same order used in query.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -