How to read text / csv file by ado.net using vb.net 2005 [modified]
-
How can I read a text or csv file by ado.net.The following code is working fine with vb 6.0 but when I try to use the same code with vb.net 2005 it gives me an error at Rcdfile.open line. The following error I am getting. [Microsoft][ODBC Text Driver]'6.0' is not a valid name.Make sure that it does not include invalid character or punctuation and that it is not too long. Here is the code which I am using to open the file. Dim Conn As New ADODB.Connection Dim RcdFile As New ADODB.Recordset Conn.Open("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & mPath & " ; ";Extensions=asc,csv,tab,txt;HDR=NO;Persist Security Info=False") RcdFile.Open("Select * From " & Me.OpenFileDialog.FileName & "", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly) Any idea where I am wrong. THanks in advance
modified on Thursday, January 24, 2008 9:39:36 AM
-
How can I read a text or csv file by ado.net.The following code is working fine with vb 6.0 but when I try to use the same code with vb.net 2005 it gives me an error at Rcdfile.open line. The following error I am getting. [Microsoft][ODBC Text Driver]'6.0' is not a valid name.Make sure that it does not include invalid character or punctuation and that it is not too long. Here is the code which I am using to open the file. Dim Conn As New ADODB.Connection Dim RcdFile As New ADODB.Recordset Conn.Open("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & mPath & " ; ";Extensions=asc,csv,tab,txt;HDR=NO;Persist Security Info=False") RcdFile.Open("Select * From " & Me.OpenFileDialog.FileName & "", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly) Any idea where I am wrong. THanks in advance
modified on Thursday, January 24, 2008 9:39:36 AM