locked
Problem with my SqlSataSource + GridView + dropdownlist RRS feed

  • Question

  • User248873758 posted

    Hello,

    I'm stuck for 2 week on a problem:

    I'am a webForm.aspx:

    <body>
        <form id="form1" runat="server">
        <div>
     
        </div>
            <asp:SqlDataSource ID="dsProfils" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT ID_PROFIL, DESCRIPTION_PROFIL FROM TBL_PROFIL"></asp:SqlDataSource>
            .<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="dsProfils" DataTextField="DESCRIPTION_PROFIL" DataValueField="DESCRIPTION_PROFIL" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                        SelectCommand="SELECT [NOM], [PRENOM], [DESCRIPTION_PROFIL], [PROFIL] FROM [VUE_RECRUTEMENT] WHERE ([DESCRIPTION_PROFIL] = @DESCRIPTION_PROFIL)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DropDownList1" Name="DESCRIPTION_PROFIL" PropertyName="SelectedValue" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
                    </asp:DataList>
        </form>
    </body>
    It makes me an ORA- 00936 error: missing expression, it does not take me the query as a parameterized query

    I use oracle developer tools for visual studio
    If i replace @DESCRIPTION_PROFIL BY 'VALUE' it works
    ==> SelectCommand="SELECT NOM, PRENOM, DESCRIPTION_PROFIL, PROFIL FROM VUE_RECRUTEMENT WHERE DESCRIPTION_PROFIL = 'Informaticien'"
    Have you any idea?

    I do not want to use C# to fix my problem
    In advance thank you



    Monday, January 26, 2015 4:05 PM

Answers

  • User-1716253493 posted

    AFAIK, oracle using ":" symbol for parameters

    Try this

    ... WHERE ([DESCRIPTION_PROFIL] = :DESCRIPTION_PROFIL)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 26, 2015 7:33 PM
  • User-271186128 posted

    Hi neotof,

    Welcome to Asp.Net forum.

    As for this issue, please refer to the following code.

    //When adding the parameters you should omit the : colon, it's only needed in your update statement.
    
    myCommand.CommandText = "UPDATE totals SET count1= (SELECT COUNT(*) FROM things WHERE date BETWEEN :StartDate AND :EndDate) ";
    
     myCommand.Parameters.AddWithValue("StartDate", startdate);
     myCommand.Parameters.AddWithValue("EndDate", enddate);
     myCommand.ExecuteNonQuery();
    

    Best Regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 27, 2015 12:07 AM
  • User248873758 posted
    Great, thank you for your reply. good day
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 27, 2015 3:39 AM

All replies

  • User-1716253493 posted

    AFAIK, oracle using ":" symbol for parameters

    Try this

    ... WHERE ([DESCRIPTION_PROFIL] = :DESCRIPTION_PROFIL)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 26, 2015 7:33 PM
  • User-271186128 posted

    Hi neotof,

    Welcome to Asp.Net forum.

    As for this issue, please refer to the following code.

    //When adding the parameters you should omit the : colon, it's only needed in your update statement.
    
    myCommand.CommandText = "UPDATE totals SET count1= (SELECT COUNT(*) FROM things WHERE date BETWEEN :StartDate AND :EndDate) ";
    
     myCommand.Parameters.AddWithValue("StartDate", startdate);
     myCommand.Parameters.AddWithValue("EndDate", enddate);
     myCommand.ExecuteNonQuery();
    

    Best Regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 27, 2015 12:07 AM
  • User248873758 posted
    Great, thank you for your reply. good day
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 27, 2015 3:39 AM