?
Solved

VB6 SQL query problem

Posted on 2008-06-11
2
Medium Priority
?
1,133 Views
Last Modified: 2010-04-21
I am using VB to get data from a Microsoft SQL database. I used Microsoft Query to generate a SQL statement. The query ran perfectly in Microsoft Query. But when I used it in my application it returned this error message.
Run-time error '-2147217900 (80040e14)': [Microsoft][ODBC SQL Server] Invalid column name 'C'.

I have tried other queries which work correctly. It seems to be the last bit that causes the problem
AND ((bmwohm.status <> ""C""))"
---Microsoft Query---
SELECT rl_lot.works_order, rl_lot.line_no, rl_lot.lot, rl_lot.expiry, bmwohm.status
FROM cs3live.scheme.bmwohm bmwohm, cs3live.scheme.rl_lot rl_lot
WHERE bmwohm.works_order = rl_lot.works_order AND ((bmwohm.status<>"C"))
 
---Code used in VB---
SQL = "SELECT rl_lot.works_order, rl_lot.line_no, rl_lot.lot, rl_lot.expiry " & _
                "FROM cs3live.scheme.bmwohm bmwohm, cs3live.scheme.rl_lot rl_lot " & _
                "WHERE bmwohm.works_order = rl_lot.works_order AND ((bmwohm.status <> ""C""))"

Open in new window

0
Comment
Question by:Randox_Laboratories
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 21758211
Hello Randox_Laboratories,

Because you either need to include "Set QUOTED_IDENTIFIER ON" in your statement or use single quotes instead (the latter is easier!)

   SQL = "SELECT rl_lot.works_order, rl_lot.line_no, rl_lot.lot, rl_lot.expiry " & _
                   "FROM cs3live.scheme.bmwohm bmwohm, cs3live.scheme.rl_lot rl_lot " & _
                   "WHERE bmwohm.works_order = rl_lot.works_order AND ((bmwohm.status <> 'C'))"

Regards,

TimCottee
0
 
LVL 1

Author Closing Comment

by:Randox_Laboratories
ID: 31466077
Thanks, that worked great.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question