DataAdapter.Fill() Misses out on one row of data

  • Thread starter Thread starter Deecrypt
  • Start date Start date
D

Deecrypt

My issue is that I am communicating data between a website and a
webservice using datasets. The datasets created by filling the
datasets with results of queries using the DataAdapter. My problem is
that for some reason, the fill method seems to miss out on exactly one
row from the database even though that row still conforms to the query
criteria. Regardless of how many rows are selected as a result of the
query, only the last row logically present in the table is not copied
into the dataset. Below is my code. May be there is something I am
overlooking.


//Assign the type and destination of the database being queried
string source = "Provider = Microsoft.JET.OLEDB.4.0;data source
= C:\\leedsuni\\mscproject\\seconddemo\\snomedepr.mdb;";

//Initialise string representing the query to search the
database
string query = "SELECT * FROM abdominalpainassessmentrecords
WHERE assessment_id = " + assessmentIDTextBox.Text + "";

//This dataset represents what has just been edited and saved
in the aap database
OleDbDataAdapter aapDataAdapter = new OleDbDataAdapter(query,
source);
DataSet aapDataSet = new DataSet();
aapDataAdapter.Fill(aapDataSet,
"abdominalpainassessmentrecords");

I'm just wondering what would make the adapter miss one row that still
conforms to the query criteria. It just seems like a bug to me.

Thank you kindly

Khurram
 
Managed to fix it. For all those out there with similar problems, I
simply separated the part that was querying the database and returning
the dataset from its original code setting and placed it in a method on
its own. This also meant that the database connection needed to be
established again, however this meant that there was data missing now.

Thought i'd share

Khurra
 
Back
Top