none
c# dataset query with parameter in main en sub query RRS feed

  • Question

  • I've got a problem when I want to use a parameter in my main and subquery. Using multipleparameters in one of the 2 is no problem, but combined gives me errors.
    The query builder doesnt give any errors but they occur when the query is added to the dataset.

    I'm using sql server and visual studio 2008

    Evert


    The error msg is
    Error 2 The left-hand side of an assignment must be a variable, property or indexer C:\Documents and Settings\Administrator\Bureaublad\ProtoType\ProtoT ype\Database1DataSet.Designer.cs 10274 13 ProtoType

    On this line of the dataset
    new global::System.Data.SqlServerCe.SqlCeParameter("@v akgroepID", global::System.Data.SqlDbType.BigInt, 8, global::System.Data.ParameterDirection.Input, true, 0, 0, "Vakgroep_ID", global::System.Data.DataRowVersion.Current, null) = new global::System.Data.SqlServerCe.SqlCeParameter();

    And the query 
    SELECT     OO_Academiejaar.OO_ACA_ID, OO_Academiejaar.ACA_ID, OO_Academiejaar.OO_ID, OO_Academiejaar.Percentage, 
                          OO_Academiejaar.StudiePunten
    FROM         OO_Academiejaar INNER JOIN
                          OpleidingsOnderdeel ON OO_Academiejaar.OO_ID = OpleidingsOnderdeel.OO_ID INNER JOIN
                          OpleidingsOnderdeel_Vakgroep ON OpleidingsOnderdeel.OO_ID = OpleidingsOnderdeel_Vakgroep.OO_ID
    WHERE     (OpleidingsOnderdeel_Vakgroep.Vakgroep_ID = @vakgroepID) AND (OO_Academiejaar.OO_ID NOT IN
                              (SELECT     OO_ID
                                FROM          Opdracht_OO
                                WHERE      (Opdracht_ID = @opdrachtID)))
    Tuesday, March 2, 2010 11:58 PM

Answers

  • On this line of the dataset
    new global::System.Data.SqlServerCe.SqlCeParameter("@v akgroepID", global::System.Data.SqlDbType.BigInt, 8, global::System.Data.ParameterDirection.Input, true, 0, 0, "Vakgroep_ID", global::System.Data.DataRowVersion.Current, null) = new global::System.Data.SqlServerCe.SqlCeParameter();

    Hi themadness,

    Why you create your SqlCeParameter like that :

    new global::System.Data.SqlServerCe.SqlCeParameter(,,,,"parameters",,,) = new global::System.Data.SqlServerCe.SqlCeParameter();

    And look your first parameter "@v akgroepID",  should it be "@vakgroepID" ?

    Best regards,
    Alex Liang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, March 4, 2010 3:54 AM
    Moderator

All replies

  • I would paste the query into SQL Server Management Studio and try to debug it there. I can't do that without having your database.  Incidentally, I just checked, SSMS does support full query design and tuning for SQLCe databases--and the engine does support subqueries.

    __________________________________________________________________
    William Vaughn
    Mentor, Consultant, Trainer, MVP
    http://betav.com
    http://betav.com/blog/billva
    http://www.hitchhikerguides.net

    “Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)”

    Please click the Mark as Answer button if a post solves your problem!

    Wednesday, March 3, 2010 6:15 PM
    Moderator
  • On this line of the dataset
    new global::System.Data.SqlServerCe.SqlCeParameter("@v akgroepID", global::System.Data.SqlDbType.BigInt, 8, global::System.Data.ParameterDirection.Input, true, 0, 0, "Vakgroep_ID", global::System.Data.DataRowVersion.Current, null) = new global::System.Data.SqlServerCe.SqlCeParameter();

    Hi themadness,

    Why you create your SqlCeParameter like that :

    new global::System.Data.SqlServerCe.SqlCeParameter(,,,,"parameters",,,) = new global::System.Data.SqlServerCe.SqlCeParameter();

    And look your first parameter "@v akgroepID",  should it be "@vakgroepID" ?

    Best regards,
    Alex Liang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, March 4, 2010 3:54 AM
    Moderator