Salve a tutti ho una grid view con una sola righa vado in modifica sul record premetto che tutti i campi sono dei template , modifico alcuni valori, clicco sull'aggiornamento esegui il codice sottostante sull'evento :
Private Sub GrdvRighe_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GrdvRighe.RowUpdating
Dim cn As New OleDbConnection
Dim cdparr As Integer
Dim sqlt As String
Dim qtax As Integer
Dim sc1x As Double
Dim sc2x As Double
Dim sc3x As Double
Dim sc4x As Double
Dim valorerx As Decimal
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\stefanog.SABIANA_WRK\Documenti\Visual Studio 2005\WebSites\Webprogetti\App_Data\job.mdb"
'cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\sabiana\Documents\Visual Studio 2008\WebSites\Webprogetti\App_Data\job.mdb"
sqlt = "UPDATE RJOBS SET qta=@qta, cdparr=@cod, sc1=@sc1, sc2=@sc2, sc3=@sc3, sc4=@sc4, valorer = @valore WHERE (ID =@id)"
cn.Open()
Dim index As Integer = GrdvRighe.EditIndex
Dim row As GridViewRow = GrdvRighe.Rows(index)
Dim id As Int32
Dim txt_idx As TextBox = CType(GrdvRighe.Rows(index).FindControl("txid"), TextBox)
id = CType(txt_idx.Text, Int32)
Dim ddlcod As DropDownList = CType(GrdvRighe.Rows(index).FindControl("ddlcode"), DropDownList)
cdparr = ddlcod.Text
Dim txt_qtax As TextBox = CType(GrdvRighe.Rows(index).FindControl("txqta"), TextBox)
qtax = CType(txt_qtax.Text, Integer)
Dim txt_sc1x As TextBox = CType(GrdvRighe.Rows(index).FindControl("txsc1"), TextBox)
sc1x = CType(txt_sc1x.Text, Integer)
Dim txt_sc2x As TextBox = CType(GrdvRighe.Rows(index).FindControl("txsc2"), TextBox)
sc2x = CType(txt_sc2x.Text, Integer)
Dim txt_sc3x As TextBox = CType(GrdvRighe.Rows(index).FindControl("txsc3"), TextBox)
sc3x = CType(txt_sc3x.Text, Integer)
Dim txt_sc4x As TextBox = CType(GrdvRighe.Rows(index).FindControl("txsc4"), TextBox)
sc4x = CType(txt_sc4x.Text, Integer)
Dim txt_valorerx As TextBox = CType(GrdvRighe.Rows(index).FindControl("txvalorer"), TextBox)
valorerx = CType(txt_valorerx.Text, Double)
Dim cm As New OleDbCommand(sqlt, cn)
cn.CreateCommand()
cm.Parameters.Add("@id", OleDbType.Integer).Value = id
cm.Parameters.Add("@qta", OleDbType.Integer).Value = qtax
cm.Parameters.Add("@cod", OleDbType.Integer).Value = cdparr
cm.Parameters.Add("@sc1", OleDbType.Integer).Value = sc1x
cm.Parameters.Add("@sc2", OleDbType.Integer).Value = sc2x
cm.Parameters.Add("@sc3", OleDbType.Integer).Value = sc3x
cm.Parameters.Add("@sc4", OleDbType.Integer).Value = sc4x
cm.Parameters.Add("@valorer", OleDbType.Decimal).Value = valorerx
cm.ExecuteNonQuery()
cm.Dispose()
cn.Close()
cn.Dispose()
' Evito che il controllo passi al Datasource per la query di update
e.Cancel = True
MA I VALORI CHE PRENDONO I PARAMETRI SONO QUELLI ANTECEDENTI alle modifiche !!!
HELP ME !!!!!!!!!!1