exception
-
hi, i am getting an exception while inserting data into a ms access database in "da.Fill(ds);" "No value given for one or more required parameters." my code is like this DataSet ds = new DataSet(); try { openconnection(); cmd = new OleDbCommand(query, con); OleDbDataAdapter oda = new OleDbDataAdapter(query, con); //fill the DataTable oda.Fill(ds); closeconnection(); return ds.Tables[0]; } catch (Exception) { return ds.Tables[0]; } finally { closeconnection(); } thanks in advance j
-
hi, i am getting an exception while inserting data into a ms access database in "da.Fill(ds);" "No value given for one or more required parameters." my code is like this DataSet ds = new DataSet(); try { openconnection(); cmd = new OleDbCommand(query, con); OleDbDataAdapter oda = new OleDbDataAdapter(query, con); //fill the DataTable oda.Fill(ds); closeconnection(); return ds.Tables[0]; } catch (Exception) { return ds.Tables[0]; } finally { closeconnection(); } thanks in advance j
-
hi, i am getting an exception while inserting data into a ms access database in "da.Fill(ds);" "No value given for one or more required parameters." my code is like this DataSet ds = new DataSet(); try { openconnection(); cmd = new OleDbCommand(query, con); OleDbDataAdapter oda = new OleDbDataAdapter(query, con); //fill the DataTable oda.Fill(ds); closeconnection(); return ds.Tables[0]; } catch (Exception) { return ds.Tables[0]; } finally { closeconnection(); } thanks in advance j
Firstly, you're attempting to fill a dataset with the results of a query, not insert data into a database with this code. Is that what you intended? Secondly, the
cmd
object is not used. I don't know if you intended this. Passing the query string to the data adapter's constructor causes it to construct its own command object for itsSelectCommand
property. You can pass your own command object by using the version of the constructor that takes anOleDbCommand
object. I think the reason for the error is that the query string has one or more ? characters in it, indicating replaceable parameters, and you've not specified the values of those parameters. You'll need to use the command'sParameters
collection for this.
DoEvents
: Generating unexpected recursion since 1991