Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> [help] Gridview In Asp Not Updating Values
dhanesh
post Jul 5 2007, 02:05 AM
Post #1


Binary Geek
Group Icon

Group: Members
Posts: 444
Joined: 4-November 05
From: The Digital Arena
Member No.: 9,440



Sorry i am just repeating a question that has been asked a million times, but every answer seems to be either too advanced or not satisfying. I have a simple gridview .. and it shows all the values in the table its connected too .. but when i edit or delete .. the values in the table do not get updated .. Here is my code .. hope you guys can help me ..

CODE
[b]1    [/b]<%@ Page Language="VB" %>
[b]2    [/b]<%@ Import Namespace="System.Data" %>
[b]3    [/b]<%@ Import Namespace="System.Data.OleDb" %>
[b]4    [/b]<script language="VB" runat="server">
[b]5    [/b]    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
[b]6    [/b]        Dim myConnection As New OleDbConnection
[b]7    [/b]        myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _
[b]8    [/b]         & "Data Source=" & Server.MapPath("App_Data\origin_ts.mdb") & ";")
[b]9    [/b]        Dim myCommand As New OleDbCommand
[b]10   [/b]        myCommand.Connection = myConnection
[b]11   [/b]        myCommand.CommandText = "SELECT * FROM TimeSheet"
[b]12   [/b]        myCommand.CommandType = CommandType.Text
[b]13   [/b]        Dim myda As New OleDbDataAdapter
[b]14   [/b]        myda.SelectCommand = myCommand
[b]15   [/b]        Dim mydg As New GridView
[b]16   [/b]        'Me.GridView1.DataBind()
[b]17   [/b]        Dim dss As New AccessDataSource
[b]18   [/b]        dss.DataBind()
[b]19   [/b]        Dim myds As New DataSet
[b]20   [/b]        myda.Fill(myds, "TimeSheet")
[b]21   [/b]
[b]22   [/b]    End Sub
[b]23   [/b]
[b]24   [/b]    Protected Sub btlogout_Click(ByVal sender As Object, ByVal e As System.EventArgs)
[b]25   [/b]        FormsAuthentication.SignOut()
[b]26   [/b]        Response.Redirect("login.aspx")
[b]27   [/b]    End Sub
[b]28   [/b]
[b]29   [/b]</script>


This is my Script code ...

Now here is my html code for the gridview:

CODE
[b]1    [/b]  <asp:AccessDataSource ID="AccessDataSource1" runat="server" ConflictDetection="CompareAllValues"
[b]2    [/b]                                DataFile="~/App_Data/origin_ts.mdb" DeleteCommand="DELETE FROM [TimeSheet] WHERE [TimeSheetID] = ? AND [Day_Date] = ? AND [UserName] = ? AND [Client Name] = ? AND [Job Description] = ? AND [Job Type] = ? AND [Hours] = ?"
[b]3    [/b]                                InsertCommand="INSERT INTO [TimeSheet] ([TimeSheetID], [Day_Date], [UserName], [Client Name], [Job Description], [Job Type], [Hours]) VALUES (?, ?, ?, ?, ?, ?, ?)"
[b]4    [/b]                                OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [TimeSheet] WHERE ([UserName] = ?)"
[b]5    [/b]                                UpdateCommand="UPDATE [TimeSheet] SET [Day_Date] = ?, [UserName] = ?, [Client Name] = ?, [Job Description] = ?, [Job Type] = ?, [Hours] = ? WHERE [TimeSheetID] = ? AND [Day_Date] = ? AND [UserName] = ? AND [Client Name] = ? AND [Job Description] = ? AND [Job Type] = ? AND [Hours] = ?">
[b]6    [/b]                                <DeleteParameters>
[b]7    [/b]                                    <asp:Parameter Name="original_TimeSheetID" Type="Int32" />
[b]8    [/b]                                    <asp:Parameter Name="original_Day_Date" Type="DateTime" />
[b]9    [/b]                                    <asp:Parameter Name="original_UserName" Type="String" />
[b]10   [/b]                                    <asp:Parameter Name="original_Client_Name" Type="String" />
[b]11   [/b]                                    <asp:Parameter Name="original_Job_Description" Type="String" />
[b]12   [/b]                                    <asp:Parameter Name="original_Job_Type" Type="String" />
[b]13   [/b]                                    <asp:Parameter Name="original_Hours" Type="Int32" />
[b]14   [/b]                                </DeleteParameters>
[b]15   [/b]                                <UpdateParameters>
[b]16   [/b]                                    <asp:Parameter Name="Day_Date" Type="DateTime" />
[b]17   [/b]                                    <asp:Parameter Name="UserName" Type="String" />
[b]18   [/b]                                    <asp:Parameter Name="Client_Name" Type="String" />
[b]19   [/b]                                    <asp:Parameter Name="Job_Description" Type="String" />
[b]20   [/b]                                    <asp:Parameter Name="Job_Type" Type="String" />
[b]21   [/b]                                    <asp:Parameter Name="Hours" Type="Int32" />
[b]22   [/b]                                    <asp:Parameter Name="original_TimeSheetID" Type="Int32" />
[b]23   [/b]                                    <asp:Parameter Name="original_Day_Date" Type="DateTime" />
[b]24   [/b]                                    <asp:Parameter Name="original_UserName" Type="String" />
[b]25   [/b]                                    <asp:Parameter Name="original_Client_Name" Type="String" />
[b]26   [/b]                                    <asp:Parameter Name="original_Job_Description" Type="String" />
[b]27   [/b]                                    <asp:Parameter Name="original_Job_Type" Type="String" />
[b]28   [/b]                                    <asp:Parameter Name="original_Hours" Type="Int32" />
[b]29   [/b]                                </UpdateParameters>
[b]30   [/b]                                <SelectParameters>
[b]31   [/b]                                    <asp:SessionParameter Name="UserName" SessionField="S2" Type="String" />
[b]32   [/b]                                </SelectParameters>
[b]33   [/b]                                <InsertParameters>
[b]34   [/b]                                    <asp:Parameter Name="TimeSheetID" Type="Int32" />
[b]35   [/b]                                    <asp:Parameter Name="Day_Date" Type="DateTime" />
[b]36   [/b]                                    <asp:Parameter Name="UserName" Type="String" />
[b]37   [/b]                                    <asp:Parameter Name="Client_Name" Type="String" />
[b]38   [/b]                                    <asp:Parameter Name="Job_Description" Type="String" />
[b]39   [/b]                                    <asp:Parameter Name="Job_Type" Type="String" />
[b]40   [/b]                                    <asp:Parameter Name="Hours" Type="Int32" />
[b]41   [/b]                                </InsertParameters>
[b]42   [/b]                            </asp:AccessDataSource>
[b]43   [/b]                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
[b]44   [/b]                                AutoGenerateColumns="False" DataKeyNames="TimeSheetID" DataSourceID="AccessDataSource1" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
[b]45   [/b]                                <Columns>
[b]46   [/b]                                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
[b]47   [/b]                                    <asp:BoundField DataField="TimeSheetID" HeaderText="TimeSheetID" InsertVisible="False"
[b]48   [/b]                                        ReadOnly="True" SortExpression="TimeSheetID" />
[b]49   [/b]                                    <asp:BoundField DataField="Day_Date" HeaderText="Day_Date" SortExpression="Day_Date" />
[b]50   [/b]                                    <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
[b]51   [/b]                                    <asp:BoundField DataField="Client Name" HeaderText="Client Name" SortExpression="Client Name" />
[b]52   [/b]                                    <asp:BoundField DataField="Job Description" HeaderText="Job Description" SortExpression="Job Description" />
[b]53   [/b]                                    <asp:BoundField DataField="Job Type" HeaderText="Job Type" SortExpression="Job Type" />
[b]54   [/b]                                    <asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" />
[b]55   [/b]                                </Columns>
[b]56   [/b]                                <FooterStyle BackColor="Tan" />
[b]57   [/b]                                <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
[b]58   [/b]                                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
[b]59   [/b]                                <HeaderStyle BackColor="Tan" Font-Bold="True" />
[b]60   [/b]                                <AlternatingRowStyle BackColor="PaleGoldenrod" />
[b]61   [/b]                            </asp:GridView>


I cant find anything wrong here, so how can i manually update this or delete a value .. or please suggest any other alternative ?

TimeSheet Table has the Following:
  • TimeSheetID --> This is the Primary Key
  • Day_Date
  • UserName
  • Client Name
  • Job Description
  • Job Types
  • Hours
And the Column names are exactly as in my table, I hope the capital and spaces don't make a difference. Should i be changing the primary key to something else ? Like Day_Date ? Cause UserName is Primary key of User table and Client Name is primary key of Client table. So basically its just 3 tables and its pretty simple, but i have no clue where i am going wrong.

Thanks in Advance .. Regards

This post has been edited by dhanesh: Jul 5 2007, 02:06 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Updating Pirated Software(14)
  2. Auto Updating With One Command!(6)
  3. Updating To phpBB 2.0.18(4)
  4. MSI Launches Updating Graphics Board(0)
  5. Updating A Database's Tables(10)
  6. Updating An Rss File Using A Php Form(1)
  7. The Question Of Ethics(5)
  8. Drupal 5 Upgrade Anyone?(2)
  9. Ajax+php+sql=simply Superb!(with Visitor Tracking) :: Section 2 (retrive Values From Database And Dynamic Update!)(2)
  10. Bios Update(11)
  11. Help Rounding Maths Values(9)
  12. Gridview Doesnt Update After Deleting A Value(1)
  13. Converting Alphanumeric Strings Into Numerical Values(4)
  14. Updating Values In A Text Box(11)
  15. Afraid Of Updating My Wordpress(2)
  1. Updating Only One Thing In A Page?(3)
  2. Updating Graphics Card Problems(11)


 



- Lo-Fi Version Time is now: 5th September 2008 - 11:07 AM