SQL aliases in Visual C++ 6.0

K

Kevin

I'm making my first attempt to put embedded
SQL in a visual C++ application and I'm
having trouble getting aliases to work.
If I try the following SQL query on MS SQL 7.0
it works fine.

SELECT MTI.Mesh_Window_ID Window_ID FROM
Mesh_Transform_Indices MTI
WHERE MTI.Mesh_Window_ID = 200

If I run the same query from visual C++ 6.0
clicking on a data view and the appropriate
database and choosing 'run' from the right
mouse button menu, I get the following error :

Syntax error (missing operator) in query expression 'MTI.Mesh_Window_ID Window_ID'

if I remove the Window_ID alias, thus

SELECT MTI.Mesh_Window_ID FROM
Mesh_Transform_Indices MTI
WHERE MTI.Mesh_Window_ID = 200

it runs. If I embed this query in C++ and try it using
CDaoQueryDef, CDaoRecordset I get the same behaviour.

As far as I know this is standard SQL. Is there some
limitation on SQL when putting it in Visual C++ code ?

Thanks for any advice

Kevin
 
J

Jack Klein

I'm making my first attempt to put embedded
SQL in a visual C++ application and I'm
having trouble getting aliases to work.
If I try the following SQL query on MS SQL 7.0
it works fine.

SELECT MTI.Mesh_Window_ID Window_ID FROM
Mesh_Transform_Indices MTI
WHERE MTI.Mesh_Window_ID = 200

[snip]

Sorry, you're off-topic here. The C++ language standard does not
define or support "embedded SQL", and the stuff you wrote above is
just a syntax error in C++.

There should be support groups on Microsoft's server
msnews.microsoft.com in the family.
 
G

GrOrH

SELECT MTI.Mesh_Window_ID Window_ID FROM
Mesh_Transform_Indices MTI
WHERE MTI.Mesh_Window_ID = 200
As far as I know this is standard SQL. Is there some
limitation on SQL when putting it in Visual C++ code ?

Thanks for any advice

Kevin

Have you tried 'SELECT MTI.Mesh_Window_ID AS Window_ID'?
Whether this works or not, your post is off topic here.
Try the microsoft.public range of newsgroups for a VC++ one, or a group
specific to your database engine.
 
K

Kevin

I don't really want to get into an argument with
the topic police. I know the SQL is correct according
to the SQL standard and it works in the MS SQL query
analyser. I know that the C++ that sends the query to
the database correctly, because I can do
other queries which don't include aliases with the
same code. So I don't need any help from SQL experts.

My question is for users of the Visual C++ environment
which does support SQL. It has a data view feature and
it allows you to run SQL scripts directly. All I want
to know is if any one else has had difficulty with
aliases or there are any differences in syntax which
apply when running these scripts from the Visual
C++ program interface. For example, I have noticed that
some sample code uses square brackets on field names.

The error that gets produced refers to the exception
message that is returned when the database rejects the
script.

I will try the other group you suggested anyway though.



My question is basically f
Jack Klein said:
I'm making my first attempt to put embedded
SQL in a visual C++ application and I'm
having trouble getting aliases to work.
If I try the following SQL query on MS SQL 7.0
it works fine.

SELECT MTI.Mesh_Window_ID Window_ID FROM
Mesh_Transform_Indices MTI
WHERE MTI.Mesh_Window_ID = 200

[snip]

Sorry, you're off-topic here. The C++ language standard does not
define or support "embedded SQL", and the stuff you wrote above is
just a syntax error in C++.

There should be support groups on Microsoft's server
msnews.microsoft.com in the news:microsoft.public.* family.
 
K

Kevin

adding 'AS'....Thanks, that did the trick.

I'll post it her for the benefit of those who come looking
for an answer to the same problem.

Is it me or is the general level of documentation for putting
SQL in Visual C++ a bit weak ?
 
J

Jack Klein

On 5 Feb 2004 10:30:33 -0800, (e-mail address removed) (Kevin) wrote in
comp.lang.c++:

Top-posting will make you about as many friends here as arguing that
you should be welcomed for off-topic questions.
I don't really want to get into an argument with
the topic police. I know the SQL is correct according
to the SQL standard and it works in the MS SQL query
analyser. I know that the C++ that sends the query to
the database correctly, because I can do
other queries which don't include aliases with the
same code. So I don't need any help from SQL experts.

My question is for users of the Visual C++ environment

[snip]

The Visual C++ environment is just as off-topic here as is SQL.
Neither of them is part of the C++ language.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top