This is a migrated thread and some comments may be shown as answers.

[Solved] problem with updating table in SQL database using radgrid

3 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rodney
Top achievements
Rank 1
Rodney asked on 16 Apr 2013, 03:21 PM
hi i have a vb web app. im using a radgrid to display the information from a SQL view and the popup edit form to edit the information in a SQL table the radgrid works and the data from the table is binded to the edit components but when i click the update button it returns a message in visual studio i have attached a screen print.
Any help to get the update working would be much appreciated.
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
            sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
        </script>
 
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1">
                    </telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
        IsSticky="True">
    </telerik:RadAjaxLoadingPanel>
 
    <div style="position: static">
 
<telerik:RadGrid ID="RadGrid1" Skin="Office2010Blue" runat="server"
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
        DataSourceID="SqlDataSource1"
        CellSpacing="0" GridLines="None"
        AutoGenerateColumns="false">
         
        <MasterTableView EditMode="PopUp" CommandItemDisplay="Top"
            DataKeyNames="Log_ID">
            <Columns>
                <telerik:GridEditCommandColumn HeaderStyle-Width="40px">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="Log_ID" HeaderText="Log_ID" UniqueName="Log_ID" HeaderStyle-Width="50px">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VUpdated" HeaderText="Updated" UniqueName="VUpdated">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VWho" HeaderText="Who" UniqueName="VWho">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VCompany" HeaderText="Company" UniqueName="VCompany">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VContact" HeaderText="Contact" UniqueName="VContact">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="VNotes" HeaderText="Notes" UniqueName="VNotes">
                    <ItemTemplate>
                    <div style="width:70px;height:19px;overflow:hidden">
                    <%# DataBinder.Eval(Container.DataItem, "VNotes")%>
                    </div>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="VSR" HeaderText="SR" UniqueName="VSR">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VLocation" HeaderText="Location" UniqueName="VLocation">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VDue_Date" HeaderText="Due_Date" UniqueName="VDue_Date">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="VComplete_Flag" HeaderText="Complete" UniqueName="VComplete_Flag">
                </telerik:GridBoundColumn>
            </Columns>
             <EditFormSettings InsertCaption="Add new item" CaptionFormatString="Edit Log_ID: {0}" CaptionDataField="Log_ID" EditFormType="Template" PopUpSettings-Modal="true">
             <PopUpSettings Modal="true" Width="900px" />
              <FormTemplate>
              <table id="table1" cellspacing="1" cellpadding="1" width="250" border="0">
              <tr>
                <td>
                    Log_ID:
                </td>
                <td>
                    <asp:Label ID="lblLog_ID" runat="server" Text='<%# Bind( "Log_ID" ) %>'></asp:Label>
                </td>
                <td rowspan="9">
 
                    <telerik:RadGrid ID="RadGrid2" runat="server" Width="400px" DataSourceID="SqlDataSource2" AutoGenerateColumns="False">            
                    <MasterTableView>
                        <Columns>
 
                            <telerik:GridBoundColumn DataField="Who" HeaderText="Who" UniqueName="Who"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Created" HeaderText="Created" UniqueName="Created"></telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn DataField="Comments" HeaderText="Comments" UniqueName="Comments">
                            <ItemTemplate>
                                <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
                            </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="Action_Type" HeaderText="Action" UniqueName="Action_Type"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Action_Date" HeaderText="Action_Date" UniqueName="Action_Date"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Due_Date" HeaderText="Due_Date" UniqueName="Due_Date"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Complete_Flag" HeaderText="Complete" UniqueName="Complete_Flag"></telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                    </telerik:RadGrid>
                 
                </td>
                </tr>
                <tr>
                <td>
                    Updated:
                </td>
                <td>
                    <asp:Label ID="lblUpdated" runat="server" Text='<%# Bind( "Updated" ) %>'></asp:Label>
                </td>
                </tr>
 
                <tr>
                <td>
                    Who:
                </td>
                <td>
                    <asp:Label ID="lblWho" runat="server" Text='<%# Bind( "Who" ) %>'></asp:Label>
 
                </td>
                </tr>
         
                <tr>
                <td>
                    Company:
                </td>
                <td>
                    <asp:TextBox ID="txtCompany" runat="server" Text='<%# Bind( "Company") %>' TabIndex="2">
                    </asp:TextBox>
                </td>
                </tr>
 
                <tr>
                <td>
                    Contact
                </td>
                <td>
                    <asp:TextBox ID="txtContact" Text='<%# Bind( "contact") %>' runat="server" TabIndex="9">
                    </asp:TextBox>
                </td>
                </tr>
 
                <tr>
                <td>
                    Header
                </td>
                <td>
                    <asp:TextBox ID="txtNotes" Text='<%# Bind( "Notes") %>' runat="server" TabIndex="8">
                    </asp:TextBox>
                </td>
                </tr>
 
                <tr>
                <td>
                    SR:
                </td>
                <td>
                    <asp:TextBox ID="txtSR" Text='<%# Bind( "SR") %>' runat="server" TabIndex="9">
                    </asp:TextBox>
                </td>
                </tr>
 
                <tr>
                <td>
                    Location:
                </td>
                <td>
                    <asp:TextBox ID="txtLocation" Text='<%# Bind( "Location") %>' runat="server" TabIndex="11">
                    </asp:TextBox>
                    <%--<telerik:RadComboBox ID="RadComboBox1" SelectedValue='<%# Bind( "Location") %>' runat="server" Skin="Office2010Blue">
                    </telerik:RadComboBox>--%>
                </td>
                </tr>
 
                <tr>
                <td>
                    Due_Date:
                </td>
                <td>
                    <telerik:RadDateTimePicker ID="RadDateTimePicker1" DbSelectedDate='<%# Bind( "Due_Date") %>' runat="server">
                    <Calendar ID="Calendar2" runat="server" EnableKeyboardNavigation="true">
                    </Calendar>
                    <DateInput ToolTip="Date input" runat="server"></DateInput>
                    </telerik:RadDateTimePicker>
                </td>
                </tr>
 
                <tr>
                <td>
                    Complete:
                </td>
                <td>
                    <telerik:RadComboBox ID="RadDropDownList1" SelectedValue='<%# Bind( "Complete_Flag") %>' runat="server" Skin="Office2010Blue">
                    <Items>
                    <telerik:RadComboBoxItem Value="1" Text="Yes" />
                    <telerik:RadComboBoxItem Value="2" Text="No" />
                    </Items>
                    </telerik:RadComboBox>
                                         
                </td>
                </tr>
                </Table>
             <table id="Table2" style="width: 100%">
                        <tr>
                            <td align="right" colspan="2">
                                 
                                  
                                <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="images/btnUpdate.png" CausesValidation="False" CommandName='<%# Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'/>
                                 
                                <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/btnCancel.png" CausesValidation="False" CommandName="Cancel"/>
                            </td>
                        </tr>
                    </table>
              
             </FormTemplate>
            </EditFormSettings>
 
        </MasterTableView>
 
 
        <ClientSettings>
        <Resizing   AllowColumnResize="False"  ClipCellContentOnResize="true" AllowResizeToFit="True" />
            <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
            <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="550px" />
        </ClientSettings>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
 
    </telerik:RadGrid>
   </div>
 
   <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:MYSQL_ISDB %>"
        ProviderName="<%$ ConnectionStrings:MYSQL_ISDB.ProviderName %>"
        SelectCommand="SELECT t_diary_all.Log_ID, vrqsummary.VUpdated, vrqsummary.VWho, vrqsummary.VCompany, vrqsummary.VContact, vrqsummary.VNotes, vrqsummary.VSR, vrqsummary.VLocation, vrqsummary.VDue_Date, vrqsummary.VComplete_Flag,
                      t_diary_all.Updated, t_diary_all.Who, t_diary_all.Company, t_diary_all.Contact, t_diary_all.Notes, t_diary_all.SR, t_diary_all.Location, t_diary_all.Due_Date, t_diary_all.Complete_Flag FROM t_diary_all INNER JOIN vrqsummary ON t_diary_all.Log_ID = vrqsummary.Log_ID"
        InsertCommand="INSERT INTO [t_diary_all] ([Log_ID], [Updated], [Who], [Company], [contact], [Notes], [SR], [Loc], [Due_Date], [Complete_Flag]) VALUES (@Log_ID, @Updated, @Who, @Company, @contact, @header, @SR, @Loc, @Due_Date, @Complete)"
        UpdateCommand="UPDATE [t_diary_all] SET [Updated] = @Updated, [Who] = @Who, [Company] = @Company, [Contact] = @Contact, [Notes] = @Notes, [SR] = @SR, [Loc] = @Loc, [Due_Date] = @Due_Date, [Complete_Flag] = @Complete_Flag WHERE [Log_ID] = @Log_ID">
        <InsertParameters>
            <asp:Parameter Name="Updated" Type="DateTime" />
            <asp:Parameter Name="Who" Type="String" />
            <asp:Parameter Name="Company" Type="String" />
            <asp:Parameter Name="Contact" Type="Int32" />
            <asp:Parameter Name="Notes" Type="String" />
            <asp:Parameter Name="SR" Type="String" />
            <asp:Parameter Name="Location" Type="Int32" />
            <asp:Parameter Name="Due_Date" Type="DateTime" />
            <asp:Parameter Name="Complete_Flag" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Updated" Type="DateTime" />
            <asp:Parameter Name="Who" Type="String" />
            <asp:Parameter Name="Company" Type="String" />
            <asp:Parameter Name="Contact" Type="Int32" />
            <asp:Parameter Name="Notes" Type="String" />
            <asp:Parameter Name="SR" Type="String" />
            <asp:Parameter Name="Location" Type="Int32" />
            <asp:Parameter Name="Due_Date" Type="DateTime" />
            <asp:Parameter Name="Complete_Flag" Type="Int32" />
            <asp:Parameter Name="Log_ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
 
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
    ConnectionString="<%$ ConnectionStrings:T_Diary_Actions %>"
    ProviderName="<%$ ConnectionStrings:T_Diary_Actions.ProviderName %>"
    SelectCommand="SELECT Log_Line_ID, Log_ID, Who, Created, Comments, Action_Type, Action_Date, Due_Date, Complete_Flag FROM t_diary_actions WHERE Log_ID = '4108'">
 
     
    </asp:SqlDataSource>

3 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 19 Apr 2013, 08:57 AM
Hello,

Could you try to set the EnableAjax property of RadAjaxManager to false and check what exception then is raised. You could attach a screenshot of the new exception as well.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Rodney
Top achievements
Rank 1
answered on 19 Apr 2013, 12:06 PM
thanks that help but now i have a sql syntax error i have attached a screen print.
0
Andrey
Telerik team
answered on 24 Apr 2013, 06:11 AM
Hello,

This is the error preventing your application from running normally. The Ajax is masking the server-side error, that is why I suggested to disable the Ajax.

Now, you should examine your Update statement and modify it in accordance with the MySql modification of SQL language.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Rodney
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Rodney
Top achievements
Rank 1
Share this question
or