Gridview not updating DB

Hi all,
it's been a long long time I don't came here, but here I am again!

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.
Here it is:

Event: "GridView1_RowUpdating"
After modifing values in "gridview1" control, i press "update" button, that obviously calls "gridview1_rowupdating" event.
All fine till here but... data values in DB (it's an access db) are not updated, they still remain the same as before.

Here below is the code, what I'm doing wrong?

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).Controls(0), TextBox).Text
id = Integer.Parse(e.RowIndex)

'i valori id ed f1 fin qua vengoo correttamente assegnati

e.Cancel = True
command.CommandText = "UPDATE tabella SET f1= @f1 where id= @id"
command.Parameters.AddWithValue("@f1", f1)
command.Parameters.Addwithvalue("@id", id)
GridView1.EditIndex = -1

Last but not least: sorry for my so bad english, hope you understand!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!