<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Gridview not updating DB' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Gridview not updating DB' posted on the 'ASP.NET' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 21:53:22 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 21:53:22 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Gridview not updating DB</title>
      <link>http://www.programmersheaven.com/mb/ASPNET/413952/413952/gridview-not-updating-db/</link>
      <description>Hi all,&lt;br /&gt;
it's been a long long time I don't came here, but here I am again!&lt;br /&gt;
&lt;br /&gt;
I'm sorry if this is (shurely) a stupid question, but I'm not able to solve a problem with an asp net 2.0/vb net code behind web application.&lt;br /&gt;
Here it is:&lt;br /&gt;
&lt;br /&gt;
Event: "GridView1_RowUpdating"&lt;br /&gt;
After modifing values in "gridview1" control, i press "update" button, that obviously calls "gridview1_rowupdating" event.&lt;br /&gt;
All fine till here but... data values in DB (it's an access db) are not updated, they still remain the same as before.&lt;br /&gt;
&lt;br /&gt;
Here below is the code, what I'm doing wrong?&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
 
 Dim strConnString As String = ConfigurationManager.ConnectionStrings("conn_oledb
").ConnectionString
        Dim conn As New OleDb.OleDbConnection(strConnString)
        Dim objreader As OleDb.OleDbDataReader
        Dim command As New OleDb.OleDbCommand
        command.Connection = conn

        Dim f1 As Long
        Dim id As Integer

        f1 = DirectCast(GridView1.Rows(e.RowIndex).Cells(1).Con
trols(0), TextBox).Text
       id = Integer.Parse(e.RowIndex)
       
       'i valori id ed f1 fin qua vengoo correttamente assegnati

        e.Cancel = True
        conn.Open()
        command.CommandText = "UPDATE tabella SET f1= @f1 where id= @id"
        command.Parameters.AddWithValue("@f1", f1)
        command.Parameters.Addwithvalue("@id", id)
        command.ExecuteNonQuery()
        GridView1.EditIndex = -1
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
P.S.&lt;br /&gt;
Last but not least: sorry for my so bad english, hope you understand!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ASPNET/413952/413952/gridview-not-updating-db/</guid>
      <pubDate>Fri, 26 Feb 2010 09:04:27 -0700</pubDate>
      <category>ASP.NET</category>
    </item>
  </channel>
</rss>