Solved

SQL SHAPE statement error

Posted on 2004-10-27
694 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
Question by:suran78
    3 Comments
     
    LVL 6

    Expert Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Prepare to Pass the CompTIA A+ 900 Series Exam

    CompTIA aims to adapt its A+ Certification to reflect the most current knowledge and skills needed by today's IT professionals--and this year's 2016 exam is harder than ever. This certification is one of the most highly-respected and sought after in IT.

    Suggested Solutions

    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    856 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

    17 Experts available now in Live!

    Get 1:1 Help Now