Results 1 to 12 of 12

Thread: [RESOLVED] Gridview Delete

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Resolved [RESOLVED] Gridview Delete

    When I click to delete a record on my grid I get this err msg: ORA-01008: not all variables bound

    My SELECT and UPDATE buttons work fine. Any suggestions?

    Code:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>" 
            
            SelectCommand="SELECT SURPLUS_YR, DIV, SEQ_NO, SURPLUS_TYPE, DECAL_NO, FIELD_DESC, FIELD_MFGR, FIELD_SERIAL_NO, ITEM_CONDITION, SURPLUS_REASON FROM SPAR_DECAL_ITEM WHERE (SURPLUS_YR = :SURPLUS_YR) AND (SEQ_NO = :SEQ_NO) AND (DIV = :DIV)" 
            DeleteCommand="DELETE FROM SPAR_DECAL_ITEM WHERE (SURPLUS_YR = :SURPLUS_YR) AND (DIV = :DIV) AND (SEQ_NO = :SEQ_NO) AND (SURPLUS_TYPE = :SURPLUS_TYPE) AND (DECAL_NO = :DECAL_NO)" 
            
            UpdateCommand="UPDATE SPAR_DECAL_ITEM SET FIELD_DESC = :FIELD_DESC, FIELD_MFGR = :FIELD_MFGR, FIELD_SERIAL_NO = :FIELD_SERIAL_NO, ITEM_CONDITION = :ITEM_CONDITION, SURPLUS_REASON = :SURPLUS_REASON WHERE (SURPLUS_YR = :SURPLUS_YR) AND (DIV = :DIV) AND (SEQ_NO = :SEQ_NO) AND (SURPLUS_TYPE = :SURPLUS_TYPE) AND (DECAL_NO = :DECAL_NO)">
            
            <SelectParameters>
                <asp:ControlParameter ControlID="txtYr" Name="SURPLUS_YR" PropertyName="Text" 
                    Type="String"  />
                <asp:ControlParameter ControlID="txtSeqNo" Name="SEQ_NO" PropertyName="Text" 
                    Type="String" />
                <asp:ControlParameter ControlID="txtDiv" Name="DIV" PropertyName="Text" 
                    Type="String" />
            </SelectParameters>
            <DeleteParameters>
                 <asp:Parameter Name="SURPLUS_YR" Type="String" />
                <asp:Parameter Name="DIV" Type="String" />
                <asp:Parameter Name="SEQ_NO" Type="String" />
                <asp:Parameter Name="SURPLUS_TYPE" Type="String" />
                <asp:Parameter Name="DECAL_NO" Type="Decimal" />
            </DeleteParameters>
    
            <UpdateParameters>
             <asp:Parameter Name="FIELD_DESC" Type="String" />
                <asp:Parameter Name="FIELD_MFGR" Type="String" />
                <asp:Parameter Name="FIELD_SERIAL_NO" Type="String" />
                <asp:Parameter Name="ITEM_CONDITION" Type="String" />
                <asp:Parameter Name="SURPLUS_REASON" Type="String" />
                <asp:Parameter Name="SURPLUS_YR" Type="String" />
                <asp:Parameter Name="DIV" Type="String" />
                <asp:Parameter Name="SEQ_NO" Type="String" />
                <asp:Parameter Name="SURPLUS_TYPE" Type="String" />
                <asp:Parameter Name="DECAL_NO" Type="Decimal" />
            </UpdateParameters>
           
            
            
        </asp:SqlDataSource>
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Delete

    Hey,

    If you run that delete query directly on the database, using replaced values, does the query work?

    Gary

  3. #3
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Cool Re: Gridview Delete

    Quote Originally Posted by EyeTalion View Post
    When I click to delete a record on my grid I get this err msg: ORA-01008: not all variables bound

    My SELECT and UPDATE buttons work fine. Any suggestions?

    Code:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>" 
            
            SelectCommand="SELECT SURPLUS_YR, DIV, SEQ_NO, SURPLUS_TYPE, DECAL_NO, FIELD_DESC, FIELD_MFGR, FIELD_SERIAL_NO, ITEM_CONDITION, SURPLUS_REASON FROM SPAR_DECAL_ITEM WHERE (SURPLUS_YR = :SURPLUS_YR) AND (SEQ_NO = :SEQ_NO) AND (DIV = :DIV)" 
            DeleteCommand="DELETE FROM SPAR_DECAL_ITEM WHERE (SURPLUS_YR = :SURPLUS_YR) AND (DIV = :DIV) AND (SEQ_NO = :SEQ_NO) AND (SURPLUS_TYPE = :SURPLUS_TYPE) AND (DECAL_NO = :DECAL_NO)" 
            
            UpdateCommand="UPDATE SPAR_DECAL_ITEM SET FIELD_DESC = :FIELD_DESC, FIELD_MFGR = :FIELD_MFGR, FIELD_SERIAL_NO = :FIELD_SERIAL_NO, ITEM_CONDITION = :ITEM_CONDITION, SURPLUS_REASON = :SURPLUS_REASON WHERE (SURPLUS_YR = :SURPLUS_YR) AND (DIV = :DIV) AND (SEQ_NO = :SEQ_NO) AND (SURPLUS_TYPE = :SURPLUS_TYPE) AND (DECAL_NO = :DECAL_NO)">
            
            <SelectParameters>
                <asp:ControlParameter ControlID="txtYr" Name="SURPLUS_YR" PropertyName="Text" 
                    Type="String"  />
                <asp:ControlParameter ControlID="txtSeqNo" Name="SEQ_NO" PropertyName="Text" 
                    Type="String" />
                <asp:ControlParameter ControlID="txtDiv" Name="DIV" PropertyName="Text" 
                    Type="String" />
            </SelectParameters>
            <DeleteParameters>
                 <asp:Parameter Name="SURPLUS_YR" Type="String" />
                <asp:Parameter Name="DIV" Type="String" />
                <asp:Parameter Name="SEQ_NO" Type="String" />
                <asp:Parameter Name="SURPLUS_TYPE" Type="String" />
                <asp:Parameter Name="DECAL_NO" Type="Decimal" />
            </DeleteParameters>
    
            <UpdateParameters>
             <asp:Parameter Name="FIELD_DESC" Type="String" />
                <asp:Parameter Name="FIELD_MFGR" Type="String" />
                <asp:Parameter Name="FIELD_SERIAL_NO" Type="String" />
                <asp:Parameter Name="ITEM_CONDITION" Type="String" />
                <asp:Parameter Name="SURPLUS_REASON" Type="String" />
                <asp:Parameter Name="SURPLUS_YR" Type="String" />
                <asp:Parameter Name="DIV" Type="String" />
                <asp:Parameter Name="SEQ_NO" Type="String" />
                <asp:Parameter Name="SURPLUS_TYPE" Type="String" />
                <asp:Parameter Name="DECAL_NO" Type="Decimal" />
            </UpdateParameters>
           
            
            
        </asp:SqlDataSource>
    hi there...this is my fav question...

    item which you are deleting...

    does it has any entry in the child table...

    if yes...

    then error is correct..

    else

    there is something else...

    check and let me know...

  4. #4

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Delete

    Yes, it does have an entry to delete? So why does this cause an error?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Delete

    Hey EyeTalion,

    Did you see my question? Does the query work directly against the database, if you replace all the parameter values?

    Gary

  6. #6
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Thumbs up Re: Gridview Delete

    Quote Originally Posted by EyeTalion View Post
    Yes, it does have an entry to delete? So why does this cause an error?
    if it has an entry i the child table then

    you are suppose to delete that record..

    then and only then it will allow you to delete record..

    to get the things automatically flushed from the child table..

    you need to do setting while setting up a relation with tables..

    there is a property called...ondeletecascade

    mark it as check...then delete won't cause any problem...

    hope that helps...

    and please follow the GEP13..

    he clearly suggested..

    is that delete query works on your SQL server..?

  7. #7

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Delete

    Gary, I was able to delete the record directly from the database....as far as the OnDeleteCascade, I don't think this is the reason I'm getting an error message, since I'm only trying to delete the child record.
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Delete

    Hey,

    Can you show the definition of your GridView?

    Gary

  9. #9

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Delete

    Code:
    <asp:GridView ID="gv" runat="server" DataSourceID="SqlDataSource1"
            
            style="top: 590px; left: 14px; position: absolute; height: 50px; width: 882px" 
            AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
            Font-Bold="False" BorderColor="#3399FF" BorderStyle="Solid" BorderWidth="1px" 
            Font-Names="Verdana" Font-Size="Small">
        <HeaderStyle BackColor="#FFFFCC" Font-Bold="True" Font-Names="Verdana" 
            Font-Size="X-Small" />
        <EditRowStyle Font-Names="Verdana" Font-Size="Small" BackColor="#E9E9E9"/>
        <AlternatingRowStyle BackColor="#E1F0FF" />
        
       </asp:gridview>
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Delete

    Hey,

    Is one of the columns you are selecting the primary key for that table?

    I think what you need to do is set the DataKeyNames property of the GridView:

    http://msdn.microsoft.com/en-us/libr...akeynames.aspx

    Gary

  11. #11

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Delete

    Thanks Gary...that was it. I didn't have the DataKeyNames set.
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Gridview Delete

    Woo Hoo!!

    Glad to hear you got it working!!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width