Hi guys, I am a bit curious why does the dataset contains only 9 rows wherein there were 10 records in a data file.
I used the following codes to retrieve data from a file...
[QUOTE]
OleDbDataAdapter oleData;
DataSet dsData = new DataSet();
string strOleConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Path.GetDirectoryName(strFile) +
";Extended Properties='text;HDR=Yes;FMT=Delimited(,)'";
string strRetrieveData = "SELECT * FROM " + Path.GetFileName(strFile);
oleCSVData = new OleDbDataAdapter(strRetrieveData, strOleConnection);
oleCSVData.Fill(dsData);
[/QUOTE]
However, if I am going to retrieve data from the file using StreamReader, I can able to retrieve all records.
Another thing, which is faster in retrieving records on a data file, is it using StreamReader or OleDB.
I need your help and guidance.
VulpesPosted Aug 4, 2012, 10:10 AM
If it isn't in fact a header, then the number of rows returned will be one less than expected. So, if this is the problem, then specifying HDR=No should fix it.
StreamReader is low level and has little overhead so it's likely to be faster than OleDb, particularly for a small number of records. On the other hand, you have to do additional programming with the former to split up your rows into their constituent columns.
boycotoPosted Aug 4, 2012, 9:26 PM