Home All Groups Group Topic Archive Search About

Open a file wiht "(" in the filename?

Author
29 Dec 2006 6:20 PM
Al G
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()

Author
29 Dec 2006 7:20 PM
Mythran
Show quote Hide quote
"Al  G" <agerhart2@nospam.charter.net> wrote in message
news:S%clh.82$Q4.43@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
Are all your drivers up to date? click for free checkup

Author
29 Dec 2006 9:02 PM
Al G
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



Show quoteHide quote
"Mythran" <kip_pot***@hotmail.com> wrote in message
news:OQ1to53KHHA.4376@TK2MSFTNGP03.phx.gbl...
>
>
> "Al  G" <agerhart2@nospam.charter.net> wrote in message
> news:S%clh.82$Q4.43@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
>
>
>
>
Author
3 Jan 2007 5:09 PM
Mythran
Show quote Hide quote
"Al  G" <agerhart2@nospam.charter.net> wrote in message
news:S%clh.82$Q4.43@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

Bookmark and Share

Post Thread options