Solved

SQL Server query returning -1 with sqldbcode 4104

Posted on 2013-12-19
4
700 Views
Last Modified: 2013-12-19
I've recently added a new query to my PowerBuilder 12.1 application which has existed (in one form or another) for over 15 years now.  This is a very simple SELECT query against a very simple database table and is similar to literally hundreds of other query statements in this application.  For some reason (and this is something I've never encountered before) this specific query is returning with an SQLCODE value of -1, SQLDBCODE value of 4104 and the following text:

SQLSTATE = 42S22
Microsoft SQL Server Native Client 10.0
The multi-part identifier "struct_key.etss_comp" could not be bound.

I've tried changing the field name a number of times, but the result is still the same.  The only thing special about this query is that it's always the FIRST database query in the application, since I'm planning on using the results to potentially "kick-off" another application based on the values in the fields returned by this query -OR- just continue with the application which will be the case 99.9% of the time.  Problem is, in order to do what I'm looking to do, I need the results from this query.  Note: Running the query in SQL Server Management Studio with hard-coded values in the WHERE clause works fine!?  I'm hoping one of you SQL Server gurus have run into this before and there's a simple solution.  If you need any additional information, please let me know.
0
Comment
Question by:Jim Klocksin
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
virtuadept earned 500 total points
ID: 39729936
Could you post the query?  

The error message indicates that SQL does not know what struct_key is.

Is the query using the text syntax or graphical mode?

Is this "classic" PowerBuilder forms or .NET?

On PowerBuilder 11.5 (haven't used 12.1) PB will actually slightly alter the query before it goes to the database. You can see what is actually being sent by turning on Trace mode on your PB connection. Here is how you do trace. In your connection object set DBMS prefix of TRACE or TRS before the DBMS name. For example:

DBMS="TRACE SNC SQL Native Client(OLE DB)"

Trace is extremely verbose and shows a lot of info you may not care about such as how PB internally treats the queries.

DBMS="TRS SNC SQL Native Client(OLE DB)"

TRS just shows the SQL syntax passed to the database for every transaction through that connection object (usually SQLCA).

Here is a link for that error message, maybe this will also help, if you read this and find something in there that would apply to your query:

http://www.microsoft.com/technet/support/ee/transform.aspx?ProdName=SQL%20Server&ProdVer=9.0&EvtID=4104&EvtSrc=MSSQLServer&LCID=1033
0
 
LVL 3

Expert Comment

by:kotukunui
ID: 39730195
As well as the query, it would be useful to see the structure of the table on which it is acting.

If you can extract and show us a DDL SQL table creation script for "struct_key" that gives us column names and datatypes (without exposing any data) we can compare that against the DML SQL to see where the mismatch happens.
0
 

Author Closing Comment

by:Jim Klocksin
ID: 39730237
This turned out to be a "really, really" dumb coding mistake.  I want to give you credit, though, for the solution, since your first statement got me thinking and made me realize what the problem was (when you said "The error message indicates that SQL does not know what struct_key is.".  My problem (typical to programming I suppose, but I should have picked up on it) was a missing colon (:).  It should have been ":struct_key" not "struct_key".  Once I added the colon, I knew it was going to work and it did.  I do thank you for pointing me in the right direction!!!
0
 
LVL 8

Expert Comment

by:virtuadept
ID: 39730325
Kudos. Well keep that tracing feature in mind too, that has come in very handy when developing PowerBuilder stuff.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

829 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