[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL SHAPE statement error

Posted on 2004-10-27
4
Medium Priority
?
715 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

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…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

656 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