Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to read text / csv file by ado.net using vb.net 2005 [modified]

How to read text / csv file by ado.net using vb.net 2005 [modified]

Scheduled Pinned Locked Moved Visual Basic
csharpsecurityhelptutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ejaz_pk
    wrote on last edited by
    #1

    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

    E 1 Reply Last reply
    0
    • E ejaz_pk

      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

      E Offline
      E Offline
      ejaz_pk
      wrote on last edited by
      #2

      I got the problem.Actually I was giving the filename with the path in the file open line where it should be only filename without path.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups