www.webdeveloper.com
Results 1 to 3 of 3

Thread: Update error in GridView

  1. #1
    Join Date
    Apr 2008
    Posts
    6

    Update error in GridView

    I use objectdatasource with GridView.
    But there is an error, when I tried to update some fields and some other fields are empty. Can anyone solve this problem?

    The error like this:
    Procedure 'xpUpdEventAutomateExtra' expects parameter '@vchExtra', which was not supplied.

    Code:
    Code
    public void xpUpdEventAutomateExtra(long biEventAutomateExtraID, long biEventAutomateID, string vchFeed, string vchSport, string vchQueryString, string vchDuration, string vchExtra, bool bAddGame, bool bXMLOnly, bool bDeleted)
        {
            SqlConnection oConn = new SqlConnection(gCS);
            oConn.Open();
            SqlCommand oCmd = new SqlCommand("xpUpdEventAutomateExtra", oConn);
            oCmd.CommandType = CommandType.StoredProcedure;//oCmd.CommandTimeout = 999999999;
    
            oCmd.Parameters.Add(new SqlParameter("@biEventAutomateExtraID", SqlDbType.BigInt, 8));
            oCmd.Parameters["@biEventAutomateExtraID"].Value = biEventAutomateExtraID;
            oCmd.Parameters["@biEventAutomateExtraID"].Direction = ParameterDirection.Input;
            oCmd.Parameters.Add(new SqlParameter("@biEventAutomateID", SqlDbType.BigInt, 8));
            oCmd.Parameters["@biEventAutomateID"].Value = biEventAutomateID;
            oCmd.Parameters["@biEventAutomateID"].Direction = ParameterDirection.Input;
           
            
            oCmd.Parameters.Add(new SqlParameter("@vchQueryString", SqlDbType.VarChar, 256));
            oCmd.Parameters["@vchQueryString"].Value = vchQueryString;
            oCmd.Parameters["@vchQueryString"].Direction = ParameterDirection.Input;
            
            oCmd.Parameters.Add(new SqlParameter("@vchDuration", SqlDbType.VarChar, 256));
            oCmd.Parameters["@vchDuration"].Value = vchDuration;
            oCmd.Parameters["@vchDuration"].Direction = ParameterDirection.Input;
            
            oCmd.Parameters.Add(new SqlParameter("@vchExtra", SqlDbType.VarChar, 256));
            oCmd.Parameters["@vchExtra"].Value = vchExtra;       
            oCmd.Parameters["@vchExtra"].Direction = ParameterDirection.Input;
    
           
            oCmd.Parameters.Add(new SqlParameter("@bXMLOnly", SqlDbType.Bit, 1));
            oCmd.Parameters["@bXMLOnly"].Value = bXMLOnly;
            oCmd.Parameters["@bXMLOnly"].Direction = ParameterDirection.Input;
            oCmd.Parameters.Add(new SqlParameter("@bDeleted", SqlDbType.Bit, 1));
            oCmd.Parameters["@bDeleted"].Value = bDeleted;
            oCmd.Parameters["@bDeleted"].Direction = ParameterDirection.Input;
            oCmd.ExecuteNonQuery();
            oCmd.Dispose();
            oConn.Close(); oConn.Dispose();
        }
    HTML Code:
    ASPX page
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="xpGetEventAutomateExtra"
                TypeName="cEvenAutomateExtraD" UpdateMethod="xpUpdEventAutomateExtra" InsertMethod="xpAddEventAutomateExtra">
                <UpdateParameters>                
                    <asp:Parameter Name="biEventAutomateExtraID" Type="Int64" />
                    <asp:Parameter Name="biEventAutomateID" Type="Int64" />
                    <asp:Parameter Name="vchFeed" Type="String" />
                    <asp:Parameter Name="vchSport" Type="String" />
                    <asp:Parameter Name="vchQueryString" Type="String" />
                    <asp:Parameter Name="vchDuration" Type="String" />
                    <asp:Parameter Name="vchExtra" Type="String" />
                    <asp:Parameter Name="bAddGame" Type="Boolean" />
                    <asp:Parameter Name="bXMLOnly" Type="Boolean" />
                    <asp:Parameter Name="bDeleted" Type="Boolean" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="biEventAutomateID" Type="Int64" />
                    <asp:Parameter Name="vchFeed" Type="String" />
                    <asp:Parameter Name="vchSport" Type="String" />
                    <asp:Parameter Name="vchQueryString" Type="String" />
                    <asp:Parameter Name="vchDuration" Type="String" />
                    <asp:Parameter Name="vchExtra" Type="String" />
                    <asp:Parameter Name="bAddGame" Type="Boolean" />
                    <asp:Parameter Name="bXMLOnly" Type="Boolean" />
                    <asp:Parameter Name="bDeleted" Type="Boolean" />
                </InsertParameters>
            </asp:ObjectDataSource>
        
        
            <asp:GridView ID="GridView1" runat="server" DataKeyNames="biEventAutomateExtraID" DataSourceID="ObjectDataSource1" AllowPaging="True" CellPadding="4" AutoGenerateEditButton="True" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px">
                <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                <RowStyle BackColor="White" ForeColor="#330099" />
                <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
               
            </asp:GridView>
        </div>
    thanks!

    _mickey

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    all I can think of, since it's a saturday morning, is maybe something like this:

    Code:
    oCmd.Parameters["@vchExtra"].Value = (vchExtra == null) ? "" : vchExtra;

  3. #3
    Join Date
    Apr 2008
    Posts
    6
    thanks Chazzy.
    That all work well.

    _mickey

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles