EDN Admin
Well-known member
Hi,
I am reading a .csv file using Oledbdatareader. As
string file = "C:\CMPNAME.csv";<br/>
string dir = Path.GetDirectoryName(file);<br/>
string excelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +<br/>
dir + @";Extended Properties=""Text;HDR=No;FMT=Delimited""";<br/>
OleDbConnection conn = new OleDbConnection(excelConn);<br/>
conn.Open();<br/>
string query = "SELECT * FROM [" + file+"]";
OleDbCommand cmd = new OleDbCommand(query, conn);<br/>
OleDbDataReader reader = cmd.ExecuteReader();<br/>
while (reader.Read())<br/>
{<br/>
MessageBox.Show(reader[0].ToString());<br/>
}
<br/>
It was failing at "OleDbDataReader reader = cmd.ExecuteReader();" by giving error as "The Microsoft Jet database engine could not find the object C:CMPNAME.csv. Make sure the object exists and that you spell its name and the path name correctly."(System.Data.OleDb.OleDbException
was unhandled)
Can any one help me.
Thanks in Advance
Sateesh
View the full article
I am reading a .csv file using Oledbdatareader. As
string file = "C:\CMPNAME.csv";<br/>
string dir = Path.GetDirectoryName(file);<br/>
string excelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +<br/>
dir + @";Extended Properties=""Text;HDR=No;FMT=Delimited""";<br/>
OleDbConnection conn = new OleDbConnection(excelConn);<br/>
conn.Open();<br/>
string query = "SELECT * FROM [" + file+"]";
OleDbCommand cmd = new OleDbCommand(query, conn);<br/>
OleDbDataReader reader = cmd.ExecuteReader();<br/>
while (reader.Read())<br/>
{<br/>
MessageBox.Show(reader[0].ToString());<br/>
}
<br/>
It was failing at "OleDbDataReader reader = cmd.ExecuteReader();" by giving error as "The Microsoft Jet database engine could not find the object C:CMPNAME.csv. Make sure the object exists and that you spell its name and the path name correctly."(System.Data.OleDb.OleDbException
was unhandled)
Can any one help me.
Thanks in Advance
Sateesh
View the full article