Solved

SQL Server query returning -1 with sqldbcode 4104

Posted on 2013-12-19
4
690 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now