473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 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 2206
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TF | last post by:
Hi, I have to access data from a comma delimited file in .net windows application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0 provider for this purpose. Now the problem is when i extract...
3
by: Chris Thunell | last post by:
I have a program where i connect to an access database and get some information out of it. I'm using the oledb.3.51 version, my computer doesn't seem to have the 4.0 version, but the computer that...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
1
by: tascien | last post by:
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...
3
by: blue875 | last post by:
When I run this connection, I get a security error. String connectStr = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"User Id=USER; Password=PASS;" + @"Data Source=\\SERVER\DIRECTORY\Data.mdb;" +...
4
by: SAL | last post by:
Hello, I am using OLEDB to access Excel, and what I have read you can access Named Ranges but I am having trouble doing so. The following are lines of code I've tried in my C# program to access...
3
by: cgcalonso | last post by:
Hi, I'm pretty new with Postgre. So far I've managed to create databases, functions, etc and access them from Windows applications written in C# via Odbc and Npgsql. I am requested to use OleDb, so I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.