Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 758
  • Last Modified:

SQL Server query returning -1 with sqldbcode 4104

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
Jim Klocksin
Asked:
Jim Klocksin
  • 2
1 Solution
 
virtuadeptCommented:
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
 
kotukunuiCommented:
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
 
Jim KlocksinOwner, Data ArchitectsAuthor Commented:
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
 
virtuadeptCommented:
Kudos. Well keep that tracing feature in mind too, that has come in very handy when developing PowerBuilder stuff.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now