471,335 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,335 software developers and data experts.

oledb invalid path...

This code is NOT working. Well, the error is saying that the path is
invalid. But how... Before i open the connection, i am doing, if
f.Exists(file) then. so, if that returns true, why the connection
thinks that the file does not exists?

Thanks for your help...

Private Sub dsConn()
Dim file As String = "mt.csv"
Dim ds As New DataSet

Try
Dim f As System.IO.File
If f.Exists(file) Then
Dim ConStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
file & ";Extended
Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " &
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MsgBox(ex.Message) <- invalid path. Make sure the file
exists... blah blah...
End Try
End Sub

Jul 21 '05 #1
1 2080
On 22 Apr 2005 12:01:58 -0700, "tascien" <ta******@ecoaches.com> wrote:

This code is NOT working. Well, the error is saying that the path is
invalid. But how... Before i open the connection, i am doing, if
f.Exists(file) then. so, if that returns true, why the connection
thinks that the file does not exists?

Thanks for your help...

Private Sub dsConn()
Dim file As String = "mt.csv"
Dim ds As New DataSet

Try
Dim f As System.IO.File
If f.Exists(file) Then
Dim ConStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
file & ";Extended
Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " &
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MsgBox(ex.Message) <- invalid path. Make sure the file
exists... blah blah...
End Try
End Sub

The Data Source should be the path to the file, excluding the file name:

Dim TextConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My
Documents\TextFiles" & ";" & _
"Extended
Properties=""Text;HDR=NO;""")
Paul
~~~~
Microsoft MVP (Visual Basic)
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Chris Thunell | last post: by
9 posts views Thread by Pam Ammond | last post: by
reply views Thread by NicK chlam via DotNetMonster.com | last post: by
1 post views Thread by tascien | last post: by
4 posts views Thread by SAL | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.