473,396 Members | 2,013 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,396 software developers and data experts.

Open a file wiht "(" in the filename?

Hi,

VS2005team(w/ sp1), VB, XP(w/ sp2)

I am attempting to open a file that has parenthesis in the filename.

The following code works OK without the "( )", but not with them. The error
is: "Command contains unrecognized phrase/keyword."

Does anyone know a way to work around this?
TicketFile = "C:\convert\Test(3).dbf"

connectionstring = "Provider=VFPOLEDB.1;Data Source=" & ticketfile &
";Collating Sequence=MACHINE"

Dim queryString As String = "SELECT * FROM " & TicketFile

Using connection As New OleDbConnection(connectionstring)

Dim command As New OleDbCommand(queryString, connection)

connection.Open()

Dim reader As OleDbDataReader = Command.ExecuteReader()
Dec 29 '06 #1
3 1424


"Al G" <ag*******@nospam.charter.netwrote in message
news:S%************@newsfe02.lga...
Hi,

VS2005team(w/ sp1), VB, XP(w/ sp2)

I am attempting to open a file that has parenthesis in the filename.

The following code works OK without the "( )", but not with them. The
error is: "Command contains unrecognized phrase/keyword."

Does anyone know a way to work around this?
TicketFile = "C:\convert\Test(3).dbf"

connectionstring = "Provider=VFPOLEDB.1;Data Source=" & ticketfile &
";Collating Sequence=MACHINE"

Dim queryString As String = "SELECT * FROM " & TicketFile

Using connection As New OleDbConnection(connectionstring)

Dim command As New OleDbCommand(queryString, connection)

connection.Open()

Dim reader As OleDbDataReader = Command.ExecuteReader()

The 'Data Source' parameter for the connection string should not be the
filename, but the path to the file instead without the file name appended.
When you perform select/update/insert/delete operations against the
connection, you specify the filename ... for example:

connString = "Provider=VFPOLEDB.1;Data Source=C:\convert\;..."
Dim queryString As String = "select * from [Test(3).dbf]"
Give that a shot and let us know how it works out for ya ;) Btw, I did not
fully test this on my end using a DBF / FoxPro file. I did, however, test
this using a comma-delimited file and it works like a charm :) I got the
information for my tests from google as well as www.connectionstrings.com.

HTH,
Mythran


Dec 29 '06 #2
Thanks Mythran,

That works perfectly. Thank you also for the link.

The working code looks like:
Dim TktQuery As String = "SELECT * FROM [" & TicketFile & "]"

Al G

"Mythran" <ki********@hotmail.comwrote in message
news:OQ**************@TK2MSFTNGP03.phx.gbl...
>

"Al G" <ag*******@nospam.charter.netwrote in message
news:S%************@newsfe02.lga...
>Hi,

VS2005team(w/ sp1), VB, XP(w/ sp2)

I am attempting to open a file that has parenthesis in the filename.

The following code works OK without the "( )", but not with them. The
error is: "Command contains unrecognized phrase/keyword."

Does anyone know a way to work around this?
TicketFile = "C:\convert\Test(3).dbf"

connectionstring = "Provider=VFPOLEDB.1;Data Source=" & ticketfile &
";Collating Sequence=MACHINE"

Dim queryString As String = "SELECT * FROM " & TicketFile

Using connection As New OleDbConnection(connectionstring)

Dim command As New OleDbCommand(queryString, connection)

connection.Open()

Dim reader As OleDbDataReader = Command.ExecuteReader()


The 'Data Source' parameter for the connection string should not be the
filename, but the path to the file instead without the file name appended.
When you perform select/update/insert/delete operations against the
connection, you specify the filename ... for example:

connString = "Provider=VFPOLEDB.1;Data Source=C:\convert\;..."
Dim queryString As String = "select * from [Test(3).dbf]"
Give that a shot and let us know how it works out for ya ;) Btw, I did
not fully test this on my end using a DBF / FoxPro file. I did, however,
test this using a comma-delimited file and it works like a charm :) I got
the information for my tests from google as well as
www.connectionstrings.com.

HTH,
Mythran


Dec 29 '06 #3


"Al G" <ag*******@nospam.charter.netwrote in message
news:S%************@newsfe02.lga...
Hi,

VS2005team(w/ sp1), VB, XP(w/ sp2)

I am attempting to open a file that has parenthesis in the filename.

The following code works OK without the "( )", but not with them. The
error is: "Command contains unrecognized phrase/keyword."

Does anyone know a way to work around this?
TicketFile = "C:\convert\Test(3).dbf"

connectionstring = "Provider=VFPOLEDB.1;Data Source=" & ticketfile &
";Collating Sequence=MACHINE"

Dim queryString As String = "SELECT * FROM " & TicketFile

Using connection As New OleDbConnection(connectionstring)

Dim command As New OleDbCommand(queryString, connection)

connection.Open()

Dim reader As OleDbDataReader = Command.ExecuteReader()

Doesn't look like my post went through last week :( Basically, don't
provide the full path to the file for the Data Source parameter of the
connection string. Instead, provide the folder name (C:\convert) as that
parameter. When you do a select, use the file name as the qualified table
name (select * from [Test(3).dbf]).

HTH,
Mythran
Jan 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Luis | last post by:
the assignment is to count the number of words in a txt file here is my code #include <iostream> #include <fstream> #include <cassert> using namespace std; int main () {
9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
0
by: Michael | last post by:
I have a problem forcing files to download. If I select Save the document is saved with no problems. If I select "Open" the document is empty or I get a "File not found" error from the application...
0
by: Steve Chatham | last post by:
I am stuck on this. It ought to be a simple reason as to why this is problematic, in that it works on smaller groups of data (say under 40 records), but doesn't on larger groups of records (40+)....
1
by: SibAndela | last post by:
Is there a way that I can attach the uploaded file from a client web site to the web server without first storing the uploaded file on the server? Currently on my local PC (local host) the...
10
by: darrel | last post by:
I have an input type="file" field that I am using to accept a file upload. This works, but I'm having problems with the filename property. In firefox, this: MyInputField.postedfile.filename ...
2
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage()...
8
by: Seth Darr | last post by:
I'm working on migrating an Classic ASP/VB6 COM application from an NT Server with IIS<6 to an virtual machine running Windows Server 2003 and IIS 6. I've worked through most of the obvious...
2
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question in relation to opening files from C#. I have a Windows form where I allow the user to type in a file extension in a text box (e.g., "xls"). I then take...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.