Connecting Tech Pros Worldwide Help | Site Map

SQL aliases in Visual C++ 6.0

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:09 AM
Kevin
Guest
 
Posts: n/a
Default SQL aliases in Visual C++ 6.0

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

  #2  
Old July 22nd, 2005, 06:09 AM
Jack Klein
Guest
 
Posts: n/a
Default Re: SQL aliases in Visual C++ 6.0

On 4 Feb 2004 18:11:57 -0800, bweep49@hotmail.com (Kevin) wrote in
comp.lang.c++:
[color=blue]
> 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[/color]

[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.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
  #3  
Old July 22nd, 2005, 06:10 AM
GrOrH
Guest
 
Posts: n/a
Default Re: SQL aliases in Visual C++ 6.0

"Kevin" <bweep49@hotmail.com> wrote in message
news:bc5096f7.0402041811.3797f591@posting.google.c om...
<snip>[color=blue]
> SELECT MTI.Mesh_Window_ID Window_ID FROM
> Mesh_Transform_Indices MTI
> WHERE MTI.Mesh_Window_ID = 200[/color]
<snip>[color=blue]
> 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[/color]

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.


  #4  
Old July 22nd, 2005, 06:10 AM
Kevin
Guest
 
Posts: n/a
Default Re: SQL aliases in Visual C++ 6.0

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 <jackklein@spamcop.net> wrote in message news:<8kb320lkad0rkdq4dsibg89q983r92vthb@4ax.com>. ..[color=blue]
> On 4 Feb 2004 18:11:57 -0800, bweep49@hotmail.com (Kevin) wrote in
> comp.lang.c++:
>[color=green]
> > 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[/color]
>
> [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.[/color]
  #5  
Old July 22nd, 2005, 06:12 AM
Kevin
Guest
 
Posts: n/a
Default Re: SQL aliases in Visual C++ 6.0

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 ?

"GrOrH" <unavailable> wrote in message news:<40222a9b$1_1@nnrp1.news.uk.psi.net>...[color=blue]
> "Kevin" <bweep49@hotmail.com> wrote in message
> news:bc5096f7.0402041811.3797f591@posting.google.c om...
> <snip>[color=green]
> > SELECT MTI.Mesh_Window_ID Window_ID FROM
> > Mesh_Transform_Indices MTI
> > WHERE MTI.Mesh_Window_ID = 200[/color]
> <snip>[color=green]
> > 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[/color]
>
> 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.[/color]
  #6  
Old July 22nd, 2005, 06:12 AM
Jack Klein
Guest
 
Posts: n/a
Default Re: SQL aliases in Visual C++ 6.0

On 5 Feb 2004 10:30:33 -0800, bweep49@hotmail.com (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.
[color=blue]
> 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[/color]

[snip]

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

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.