Re: Column_Name with periods in name



pb wrote:
Thanks for your comments, but as a software developer I can't control
what users call fields in their databases,

You have my sympathies. I suspect other problems have yet to be discovered.

and there are other
databases being hooked into apart from SQL Server. It does actually
happen that periods are used in field names, which is how a user
discovered the error in my software. I don't see why rsSchema!
Column_Name returns an interpretation of the column name rather than
the real column name.

I suggested a very valid reason. Periods are used by many databases (not
just SQL Server) to form explicilty qualify table names. Also, ADO itself
uses periods for this purpose, which I suspect goes a long way toward
explaing the reason for this behavior.

I'll try your suggestion to see what happens.

If neither of those suggestions handles it, then you are going to have to
fall back on checking the retrieved column names, and if they contain a
hash, try running a sql statement that uses that name (something like
"select <suspect column name> from table where 1=2"), catching the error if
the object does not exist. At this point, I would display a message to the
user, explaining that periods in column names violate ANSI SQL standards
causing most client applications to have trouble processing that column
name, and strongly suggesting that they change the name of the column,
replacing the period. You might even offer to change the name of the column
for them. I would provide a way for the user to tell me to go ahead and
rename the column, or exit while he goes and changes the name of the column,
or go ahead and use the column as-is. If the latter option is selected, then
it's a matter of verifying that the offending character is a period, using
the method I previously described, and keeping in mind that you will need to
surround the column name with brackets to prevent the parser from choking on
it. Something like "select [my.column] from table where 1=2". You will need
to watch out for column names containing both # and period (my.field#3). You
should consider storing this metadata somewhere so you don't have to go
through this process every time the user runs your application.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: why>?
    ... On your desktop-- you'll be running SQL Server behind the scenes. ... it isn't risky to allow end users to create databases. ... it is no more risky than giving you the ability to create spreadsheets. ... I'm not saying that Oracle and IBM are going away. ...
    (microsoft.public.excel)
  • Re: Please answer my queries for fresh Installation
    ... Moving SQL Server Databases ... Using WITH MOVE in a Restore to a New Location with Detach/Attach ... Disaster Recovery Articles for SQL Server ...
    (microsoft.public.sqlserver.server)
  • Re: Please answer my queries for fresh Installation
    ... You can restore MSDB as well as master. ... > SQL Server, It will create Master, MSDB databases. ...
    (microsoft.public.sqlserver.server)
  • Re: Moving SQL Server 2000 from NT4.0 to Windows 2003
    ... Detach your existing user databases, ... user databases (or RESTORE) to the new server. ... > Hey Steve, ... Windows 2003 will not allow SQL Server SP less than 3. ...
    (microsoft.public.sqlserver.server)
  • Re: The best elegant solution to override 65k rows limit in a sheet
    ... MDB is friggin dead.. ... SQL Server has taken over the world. ... than read-only access to central company databases. ... I learned to write queries in Access after an hours' ...
    (microsoft.public.excel)