Ways to deal with a "-" character

G

Guest

I am trying to use a String as part of a query. Here is the line:

strQuery = "Select Filename, Path from d11mw-zes215643.System..SCOPE() where
Filename = 'main.swf'"

The code works IF I rename the target workstation and remove the - character
and then adjust my code accordingly. However, that isn't a real solution for
me, so what are ways to deal with the - character so that the code can handle
it?

Here is a reference I found pertaining to C# in the middle of this page, but
I can't do the exact same thing in VB.NET...

http://www.sellsbrothers.com/news/showTopic.aspx?ixTopic=1949

Thanks
 
G

Guest

Military Smurf,

If the article is correct that you need to surround the name with
double-quote characters then you can do that in VB by using 2 double-quote
characters, like this:

strQuery = "Select Filename, Path from ""d11mw-zes215643"".System..SCOPE()
where Filename = 'main.swf'"

Kerry Moorman
 
Z

zacks

I am trying to use a String as part of a query. Here is the line:

strQuery = "Select Filename, Path from d11mw-zes215643.System..SCOPE() where
Filename = 'main.swf'"

The code works IF I rename the target workstation and remove the - character
and then adjust my code accordingly. However, that isn't a real solution for
me, so what are ways to deal with the - character so that the code can handle
it?

Here is a reference I found pertaining to C# in the middle of this page, but
I can't do the exact same thing in VB.NET...

http://www.sellsbrothers.com/news/showTopic.aspx?ixTopic=1949

Thanks

Not sure if it works for you in this case, but I do know that if a SQL
object like a table name or a column name has embedded spaces in it
you must enclose the object's name inside square brackets in the SQL
statement as in:

strQuery = "Select Filename, Path from [d11mw-
zes215643].System..SCOPE() where
Filename = 'main.swf'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top