Paul Clement
7/26/2005 1:38:00 PM
On 25 Jul 2005 06:32:06 -0700, alexbalaev@yahoo.com wrote:
¤ Hello,
¤ I am trying to read an exported Event Log Viewer file saved as a CSV
¤ with the code below and the very last line gives me "System Error".
¤ I have Framework 1.1 (1.1.4322 SP1) and VS .NET 2003 (7.1.3088)
¤ I would really appreciate if someone could help me to find out what''s
¤ wrong with it.
¤ TIA, Alex.
¤
¤ ****************************************************
¤ string strConn = "Driver={Microsoft Text Driver (*.txt;
¤ *.csv)};DBQ=d:\\";
¤ string strQuery = @"SELECT * FROM applocal.csv";
¤ OdbcConnection myConnection = new OdbcConnection(strConn);
¤ OdbcCommand myCommand = new OdbcCommand(strQuery,myConnection);
¤ OdbcDataAdapter adapter = new OdbcDataAdapter(myCommand);
¤ myConnection.Open();
¤ DataSet dtset = new DataSet();
¤ dtset.Tables.Add("TABLE1");
¤ adapter.Fill(dtset, "TABLE1");
I would recommend using the Jet OLEDB instead of the Text ODBC driver:
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "D:\" & ";" & _
"Extended Properties=""Text;HDR=No"""
Dim TextConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
TextConnection.Open()
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from applocal.csv",
TextConnection)
Dim ds As New DataSet()
da.Fill(ds, "TABLE1")
Paul
~~~~
Microsoft MVP (Visual Basic)