Escaping special character

  • Thread starter Thread starter nicolasr
  • Start date Start date
N

nicolasr

Hi,

I'm pretty new to ADO.NET and SQL and want to read in data from an Access
database. The problem is that the table I want to read data from has some
column names that contain a '-' charcter, f.e. 'Online-Kompass'.
When executing a SELECT command like
SELECT Online-Kompass FROM TheTable
I get a rather uninformative error but I assume it's because of the '-'
char.
Can anyone help how to handle this case?

thanks,
Nick
 
You can escape it with [Online-Kompass] but IMHO, hyphens in Table names is
nothing but trouble. Change it to Online_Kompass and never worry about it
again.

Cheers,

Bill
 
thanks Bill for the quick reply!
It seems to work great! I have other column names including '/' and it still
works.
Unfortunately I don't have influence on the table design. Since MS Access
allows those row names I can't prevent my users from naming them like
that...

thanks again,
Nick
 
On Thu, 11 Sep 2003 04:46:14 +0200, "nicolasr" <nicolasrNOSPAMATSIGNgmx.net> wrote:

¤ thanks Bill for the quick reply!
¤ It seems to work great! I have other column names including '/' and it still
¤ works.
¤ Unfortunately I don't have influence on the table design. Since MS Access
¤ allows those row names I can't prevent my users from naming them like
¤ that...

Enclosing the field name within brackets will resolve the problem:

SELECT [Online-Kompass] FROM TheTable


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top