Bill,
Just a guess here... If there is no header first line in the text file,
try adding "HDR=No" to your connect string.
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
"Bill Pierce" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> I need some help/verificaion of my problem. The code below works just fine.
> Data is read from a text file using the OLE DB Jet provider, parsed, and
> then imported into another database. However, the first line of the text
> file is not read. A single line text file never enters the while loop, and
> if I copy and paste that same line into the file again, one of them (the
> second one) is read and properly imported into the database.
>
> Please help me see what I am missing. Is the ...while( kOdr.Read() )... the
> proper way to prime the DataReader?
>
> -Any help is always appreciated-
>
> private OleDbConnection con;
> private string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=@;Extended Properties='text;FMT=Delimited(,)'";
>
> private void OpenDb(string pDbPath)
> {
> string tConStr = conStr.Replace("@", pDbPath);
> if( con == null )
> {
> con = new OleDbConnection(tConStr);
> con.Open();
> }
> }
>
> private void OpenTable(string pFileName, out OleDbDataReader odr)
> {
> string strSql = "SELECT * FROM " + pFileName;
> OleDbCommand cmd = new OleDbCommand(strSql, con);
> cmd.CommandType = CommandType.Text;
> odr = null;
> odr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
> }
>
> private void CloseDb()
> {
> if( con != null )
> con.Close();
> }
>
> private void DisposeDb()
> {
> if( con != null )
> {
> con.Dispose();
> con = null;
> }
> }
>
> public void ImportData()
> {
> OleDbDataReader kOdr = null;
> OpenDb();
> OpenTable("C:\test.txt",kOdr);
> while( kOdr.Read() )
> {
> // ...Parse Data and Import to Database...
> }
> kOdr = null;
> CloseDb();
> DisposeDb();
> }
>
>