SQL SHAPE statement error

I am using SHAPE-APPEND-RELATE stmt.  I need immediate help.

I am using ado, asp to display results of the SHAPE statement on webpage.  The problem is that one SHAPE stmt is working fine but when I am replacing it with anothre similar SHAPe stmt which different table and column names, it is constantly giving me syntax or access violation error.

This one is working:
sqlStmtF = SHAPE {SELECT DISTINCT F.FabricID, F.SampleName FROM
(SELECT Fabrics.FabricID, Fabrics.SampleName FROM Fabrics) F,
(SELECT P.FabricID FROM PropertyData P WHERE P.PropertyID = 1) P1
WHERE (F.FabricID = P1.FabricID) ORDER BY F.SampleName}
APPEND
({SELECT FabricID, PropertyID, PropertyValue FROM PropertyData
WHERE (PropertyID = 1) ORDER BY PropertyID}
RELATE FabricID TO FabricID) AS Properties

while this one is not, even though there  us no syntax error and I checked the sql stmt embedded inside, they are giving correct results. Then why is this not workin????

SHAPE {SELECT DISTINCT F.FabricID, F.SampleName FROM
(SELECT Fabrics.FabricID, Fabrics.SampleName FROM Fabrics) F,
(SELECT BP.FabricID FROM BasicPropertyData BP WHERE BP.BasicPropertyDataID = 2) BP2
WHERE (F.FabricID = BP2.FabricID) ORDER BY F.SampleName}
APPEND
({SELECT FabricID, BasicPropertyDataID, PropertyValue FROM BasicPropertyData
WHERE (BasicPropertyDataID = 2) ORDER BY BasicPropertyDataID}
RELATE FabricID TO FabricID) AS BasicProperties
suran78Asked:
Who is Participating?
 
NArentzCommented:
Hi,

You can't run the SHAPE statement in Query Analyzer as it requires the MSDataShape Provider not the ODBC SQL Server Driver so both statements will generate the "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" error. I suggest that you check your connection string to make sure that you are specifying the correct provider as well as checking that each part of the SHAPE statement is valid SQL. For example test that the following SQL statments return the expected results:

1. SELECT Fabrics.FabricID, Fabrics.SampleName FROM Fabrics
2. SELECT BP.FabricID FROM BasicPropertyData BP WHERE BP.BasicPropertyDataID = 2
3. SELECT DISTINCT F.FabricID, F.SampleName FROM
    (SELECT Fabrics.FabricID, Fabrics.SampleName FROM Fabrics) F,
    (SELECT BP.FabricID FROM BasicPropertyData BP WHERE BP.BasicPropertyDataID = 2) BP2
    WHERE (F.FabricID = BP2.FabricID) ORDER BY F.SampleName
4. SELECT FabricID, BasicPropertyDataID, PropertyValue FROM BasicPropertyData
    WHERE (BasicPropertyDataID = 2) ORDER BY BasicPropertyDataID

Also check that the tables you are using have fields that can be linked eg same data types. This sounds really basic but it is easy to forget the data types and mismatch them. The connection string should start with "Provider=MSDataShape;".

Hope this helps,

NArentz
0
 
Duane LawrenceCommented:
You need to divide and conquer, in other word find out if the problem is in the SQL or on the webpage.

Open query analyser, run the bottom one.  If it runs fine, then the problem is in the webpage.

Duane
0
 
suran78Author Commented:
the sql query analyser is giving this error for both the SHAPE stmt:

[Microsoft][ODBC SQL Server Driver]Syntax error or access violation

How come the first SHAPe statement is working fine in the website ???
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.

All Courses

From novice to tech pro — start learning today.