Click here to Skip to main content
15,917,628 members

Comments by Member 3042184 (Top 2 by date)

Member 3042184 8-Mar-11 12:27pm View    
I use database SQL6.5 and VS2010 express. This code does not work.
I use another one now
Protected Sub Gridview1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)

Dim dt = CType(Session("dtParams"), DataTable)

.
Dim row = Gridview1.Rows(e.RowIndex)

dt.Rows(row.DataItemIndex)("ParameterId") = (CType(row.FindControl("lblParameterId"), Label)).Text
dt.Rows(row.DataItemIndex)("ParamName") = (CType(row.FindControl("txtParamName"), TextBox)).Text

dt.Rows(row.DataItemIndex)("mnemonic") = (CType(row.FindControl("txtmnemonic"), TextBox)).Text
dt.Rows(row.DataItemIndex)("Condition1Min") = (CType(row.FindControl("txtCondition1Min"), TextBox)).Text
dt.Rows(row.DataItemIndex)("Level1Min") = (CType(row.FindControl("txtLevel1Min"), TextBox)).Text
dt.Rows(row.DataItemIndex)("Condition0Min") = (CType(row.FindControl("txtCondition0Min"), TextBox)).Text

If (CType(row.FindControl("txtLevel0Min"), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex)("Level0Min") = (CType(row.FindControl("txtLevel0Min"), TextBox)).Text
Else
dt.Rows(row.DataItemIndex)("Level0Min") = DBNull.Value
End If

dt.Rows(row.DataItemIndex)("Condition0Max") = (CType(row.FindControl("txtCondition0Max"), TextBox)).Text

If (CType(row.FindControl("txtLevel0Max"), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex)("Level0Max") = (CType(row.FindControl("txtLevel0Max"), TextBox)).Text
Else
dt.Rows(row.DataItemIndex)("Level0Max") = DBNull.Value
End If

dt.Rows(row.DataItemIndex)("Condition1Max") = (CType(row.FindControl("txtCondition1Max"), TextBox)).Text


If (CType(row.FindControl("txtLevel1Max"), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex)("Level1Max") = (CType(row.FindControl("txtLevel1Max"), TextBox)).Text
Else
dt.Rows(row.DataItemIndex)("Level0Max") = DBNull.Value
End If


If (CType(row.FindControl("txtMCL"), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex)("Level1Max") = (CType(row.FindControl("txtMCL"), TextBox)).Text
Else
dt.Rows(row.DataItemIndex)("MCL") = DBNull.Value
End If

Gridview1.EditIndex = -1

BindGrid()
End Sub
It does not give an error
But it does not update.
Member 3042184 7-Mar-11 15:47pm View    
Thank you! This is my code. And it does not update!?
Public Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)

Dim connectionString As String = ConfigurationManager.ConnectionStrings("LIMS_ODBC").ConnectionString
Dim dbConnection As New Odbc.OdbcConnection(connectionString)
Dim cmd As New OdbcCommand
With cmd
cmd.CommandType = CommandType.Text
cmd.CommandText = "UPDATE Regulated " & _
"SET " & _
"ParamName = @ParamName , " & _
"mnemonic = @mnemonic , " & _
"Condition1Min =@Condition1Min, " & _
"Level1Min = @Level1Min , " & _
"Condition0Min = @Condition0Min, " & _
"Level0Min = @Level0Min, " & _
"Condition0Max = @Condition0Max , " & _
"Level0Max =@Level0Max, " & _
"Condition1Max = @Condition1Max, " & _
"Level1Max =@Level1Max, " & _
"MCL = @MCL " & _
"WHERE ParameterID = @ParameterId"


cmd.Parameters.AddWithValue("@ParamName", OdbcType.Char).Value = GridView1.Rows(e.RowIndex).FindControl("ParamName")
cmd.Parameters.AddWithValue("@mnemonic", OdbcType.Char).Value = GridView1.Rows(e.RowIndex).FindControl("mnemonic")
cmd.Parameters.AddWithValue("@Condition1Min", OdbcType.Char).Value = GridView1.Rows(e.RowIndex).FindControl("Condition1Min")
cmd.Parameters.AddWithValue("@Level1Min", OdbcType.Double).Value = GridView1.Rows(e.RowIndex).FindControl("Level1Min")
cmd.Parameters.AddWithValue("@Condition0Min", OdbcType.Char).Value = GridView1.Rows(e.RowIndex).FindControl("Condition0Min")
cmd.Parameters.AddWithValue("@Level0Min", OdbcType.Double).Value = GridView1.Rows(e.RowIndex).FindControl("Level0Min")
cmd.Parameters.AddWithValue("@Condition0Max", OdbcType.Char).Value = GridView1.Rows(e.RowIndex).FindControl("Condition0Max")
cmd.Parameters.AddWithValue("@Level0Max", OdbcType.Double).Value = GridView1.Rows(e.RowIndex).FindControl("Level0Max")
cmd.Parameters.AddWithValue("@Condition1Max", OdbcType.Char).Value = GridView1.Rows(e.RowIndex).FindControl("Condition1Max")
cmd.Parameters.AddWithValue("@Level1Max", OdbcType.Double).Value = GridView1.Rows(e.RowIndex).FindControl("level1Max")
cmd.Parameters.AddWithValue("@MCL", OdbcType.Double).Value = GridView1.Rows(e.RowIndex).FindControl("MCL")

End With
GridView1.EditIndex = -1
BindGrid()
End Sub