Hello,
I am having issues updating fields I edit in my gridview. When I try to edit a field and click update, my edits to not update to SQL Server? They revert back to the old data... I was getting an error that said I needed to use DataKeyNames for updating. I have since added it with my appropriate boundfield names, and the page does not error. I still cannot update to the SQL Server. I am unsure on how to check this operation for errors as to why I cannot update to SQL server. I am using .Net 2.0 VB.net 2005
I ahve verified my Update statement in SQL Server & VB Query Builder and I am guessing the problem lies somewhere in the variables being sent , or not being sent, to the server?
Here is my code...
Is there a way to step through this to check what is being sent to SQL? I am use to VB IDE :-(
Thanks
I am having issues updating fields I edit in my gridview. When I try to edit a field and click update, my edits to not update to SQL Server? They revert back to the old data... I was getting an error that said I needed to use DataKeyNames for updating. I have since added it with my appropriate boundfield names, and the page does not error. I still cannot update to the SQL Server. I am unsure on how to check this operation for errors as to why I cannot update to SQL server. I am using .Net 2.0 VB.net 2005
I ahve verified my Update statement in SQL Server & VB Query Builder and I am guessing the problem lies somewhere in the variables being sent , or not being sent, to the server?
Here is my code...
Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="EditJob.aspx.vb" Inherits="Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=ADMINSERVER;Initial Catalog=WWTPITWMS;Persist Security Info=True;User ID=sa;Password=Password;Pooling=False"
DeleteCommand="DELETE FROM [TBLJob] WHERE [JobID] = @JobID" InsertCommand="INSERT INTO [TBLJob] ([ComputerID], [UserID], [SoftwareID], [ErrorID], [WorkerID], [WorkOrderNum], [DateTime], [Hardware], [Software], [JobDescription], [Status]) VALUES (@ComputerID, @UserID, @SoftwareID, @ErrorID, @WorkerID, @WorkOrderNum, @DateTime, @Hardware, @Software, @JobDescription, @Status)"
SelectCommand="SELECT TBLJob.JobID, TBLJob.WorkerID, TBLJob.WorkOrderNum, TBLJob.DateTime, TBLJob.Hardware, TBLJob.Software, TBLJob.JobDescription, TBLJob.Status, TBLSoftware.SoftwareTitle, TBLUsers.UserName, TBLComputer.ComputerName, TBLError.ErrorDescription, TBLError.EventID FROM TBLJob INNER JOIN TBLComputer ON TBLJob.ComputerID = TBLComputer.ComputerID INNER JOIN TBLUsers ON TBLJob.UserID = TBLUsers.UserID INNER JOIN TBLSoftware ON TBLJob.SoftwareID = TBLSoftware.SoftwareID INNER JOIN TBLError ON TBLJob.ErrorID = TBLError.ErrorID AND TBLSoftware.SoftwareID = TBLError.SoftwareID"
UpdateCommand="UPDATE TBLJob SET UserID = (SELECT UserID FROM TBLUsers WHERE (UserName = @UserID)), ComputerID = (SELECT ComputerID FROM TBLComputer WHERE (ComputerName = @ComputerID)), SoftwareID = (SELECT SoftwareID FROM TBLSoftware WHERE (SoftwareTitle = @SoftwareID)), ErrorID = (SELECT ErrorID FROM TBLError WHERE (ErrorDescription = @ErrorID)), WorkerID = (SELECT WorkerID FROM TBLWorker WHERE (WorkerName = @WorkerID)), WorkOrderNum = @WorkOrderNum, DateTime = @DateTime, Hardware = @Hardware, Software = @Software, JobDescription = @JobDescription, Status = @Status WHERE (JobID = @JobID)">
<DeleteParameters>
<asp:Parameter Name="JobID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="GridView1" Name="UserID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Name="ComputerID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Name="SoftwareID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Name="ErrorID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Name="WorkerID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Name="WorkOrderNum" PropertyName="SelectedValue"
Type="Decimal" />
<asp:ControlParameter ControlID="GridView1" Name="DateTime" PropertyName="SelectedValue"
Type="DateTime" />
<asp:ControlParameter ControlID="GridView1" Name="Hardware" PropertyName="SelectedValue"
Type="Boolean" />
<asp:ControlParameter ControlID="GridView1" Name="Software" PropertyName="SelectedValue"
Type="Boolean" />
<asp:ControlParameter ControlID="GridView1" Name="JobDescription" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="Status" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="@JobID" PropertyName="SelectedValue" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ComputerID" Type="Int32" />
<asp:Parameter Name="UserID" Type="Int32" />
<asp:Parameter Name="SoftwareID" Type="Int32" />
<asp:Parameter Name="ErrorID" Type="Int32" />
<asp:Parameter Name="WorkerID" Type="Int32" />
<asp:Parameter Name="WorkOrderNum" Type="Decimal" />
<asp:Parameter Name="DateTime" Type="DateTime" />
<asp:Parameter Name="Hardware" Type="Boolean" />
<asp:Parameter Name="Software" Type="Boolean" />
<asp:Parameter Name="JobDescription" Type="String" />
<asp:Parameter Name="Status" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" DataKeyNames="UserName,ComputerName,softwareTitle,ErrorDescription,DateTime,Hardware,Software,Jobdescription,Status" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="DateTime" DataFormatString="{0:MM/dd/yyyy}" HeaderText="DateTime"
HtmlEncode="False" SortExpression="DateTime" />
<asp:BoundField DataField="Hardware" HeaderText="Hardware" SortExpression="Hardware" />
<asp:BoundField DataField="Software" HeaderText="Software" SortExpression="Software" />
<asp:BoundField DataField="JobDescription" HeaderText="JobDescription" SortExpression="JobDescription" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="SoftwareTitle" HeaderText="SoftwareTitle" SortExpression="SoftwareTitle" />
<asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
<asp:BoundField DataField="ComputerName" HeaderText="ComputerName" SortExpression="ComputerName" />
<asp:BoundField DataField="ErrorDescription" HeaderText="ErrorDescription" SortExpression="ErrorDescription" />
<asp:BoundField DataField="EventID" HeaderText="EventID" SortExpression="EventID" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:WWTPITWMSConnectionString %>"
SelectCommand="SELECT [SoftwareID], [SoftwareTitle] FROM [TBLSoftware]"></asp:SqlDataSource>
</asp:Content>
Is there a way to step through this to check what is being sent to SQL? I am use to VB IDE :-(
Thanks