Re: Column_Name with periods in name



Thanks for your comments, but as a software developer I can't control
what users call fields in their databases, 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'll try your suggestion to see what happens.

Pb.


On May 22, 10:46 am, "Bob Barrows [MVP]" <reb01...@xxxxxxxxxxxxxxx>
wrote:
pb wrote:
Hi,

I am trying to retreive the column names from a database table using
something like

Dim aRestrictions As Variant
aRestrictions = Array(Empty, Empty, strTableName, Empty)
Set rsSchema = cnSim.OpenSchema(adSchemaColumns, aRestrictions)

Do Until rsSchema.EOF = True
i = i + 1
colnames(i) = rsSchema!Column_Name
rsSchema.MoveNext
Loop

What I am finding is that if the real column name contains a period,

<gasp>
Seriously???? Periods?!?!?

You do realize that in SQL Server, periods are used as delimiters in the
naming convention ...

what is returned from ADO is the period replace with a hash.

eg.

my.fieldname >> my#fieldname

I'm amazed it handles it at all ...



This is not a problem when running queries derived from the extracted
field names, as it deals with them quite well. For example, two
similar names such as A#A and A.A become A#A and A#A1

My issue is that I want the REAL field name, as I then use it to go
and generate some SQL. If I currently run the SQL on the field names
returned by ADO then it spits the dummy as some of the field names
don't exist in the database.

I could replace and '#' that is returned with '.', but I'd be guessing
that it was not suppose to be a # in the first place.

Has anyone come accross this

No, of course not.

and is there a solution?

Stop using periods in column names.

Try using ADOX to retrieve the column names.

Try opening a recordset using where 1=2 so you don't retrieve any data, and
loop through the Fields collection to see if the real names are retrieved
this way.

But seriously .... stop using periods in column names!

--
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"- Hide quoted text -

- Show quoted text -


.



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)