Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 SQL query problem

Posted on 2008-06-11
2
Medium Priority
?
1,135 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

636 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