Can anyone tell me where I am going wrong? I have a simple gridview. I can view the data and I have gotten the insert to work (code behind).
But I can’t get the delete and update command commands to work. It is like the SQL fails at time of execution, and I am not sure how to trap the error that might tell me what is going on. Any suggestions would be much appreciated. I’ve tried finding the answer for about a day now.Code:Dim vRepairId As String = Request.QueryString("REPAIRID") SqlDS_WOAccount.InsertParameters("WorkOrderID").DefaultValue = vRepairId SqlDS_WOAccount.Insert()Code below:
ThanksCode:<asp:GridView ID="GridViewAccount" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDS_WOAccount" Font-Size="8pt" Width="100%"> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" > <ItemStyle HorizontalAlign="Center" Width="12%" /> </asp:CommandField> <asp:BoundField DataField="WOAcctDesc" HeaderText="Account Description" SortExpression="WOAcctDesc" /> <asp:BoundField DataField="WOAcctNumber" HeaderText="Account Number" SortExpression="WOAcctNumber"> <ItemStyle Width="38%" HorizontalAlign="Right" /> </asp:BoundField> </Columns> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <AlternatingRowStyle BackColor="#F7F7F7" /> </asp:GridView> <asp:SqlDataSource ID="SqlDS_WOAccount" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [WorkOrderAcctID], [WOAcctNumber], [WOAcctDesc], [WorkOrderID] FROM [WOAcct] WHERE ([WorkOrderID] = @WorkOrderID)" DeleteCommand="DELETE FROM [WOAcct] WHERE [WorkOrderAcctID] = @WorkOrderAcctID" InsertCommand="INSERT INTO [WOAcct] ([WorkOrderID], [WOAcctDesc]) VALUES (@WorkOrderID, 'Select Account')" UpdateCommand="UPDATE [WOAcct] SET [WOAcctNumber] = @WOAcctNumber, [WOAcctDesc] = @WOAcctDesc WHERE [WorkOrderAcctID] = @WorkOrderAcctID"> <SelectParameters> <asp:ControlParameter ControlID="txtWtrSysRepairID" Name="WorkOrderID" PropertyName="Text" Type="Int32" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="WorkOrderAcctID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="WOAcctNumber" Type="String" /> <asp:Parameter Name="WOAcctDesc" Type="String" /> <asp:Parameter Name="WorkOrderAcctID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="WorkOrderID" Type="Int32" /> </InsertParameters> </asp:SqlDataSource>




Code below:
Reply With Quote