?
Solved

SQL SHAPE statement error

Posted on 2004-10-27
4
Medium Priority
?
718 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:suran78
3 Comments
 
LVL 6

Expert Comment

by:Duane Lawrence
ID: 12426106
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
 

Author Comment

by:suran78
ID: 12426180
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
 
LVL 2

Accepted Solution

by:
NArentz earned 2000 total points
ID: 12430347
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Ready to get certified? Check out some courses that help you prepare for third-party exams.
In this article, we will show how to detach and attach a database and then show how to repair a corrupt database and attach it, If it has some errors. We will show how to detach and attach using SSMS or using T-SQL sentences.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

598 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