Protected Sub dgResult_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgResult.ItemCommand
If strErr = "" Then
Dim ddl As DropDownList = CType(e.Item.FindControl("ddlClassificationType"), DropDownList)
Dim defaultValue As Boolean = ddl.SelectedItem.Text.Contains("*")
Dim originalValue As String = String.Empty
If defaultValue = False Then
'update AppDetail
strErr = appDetailDBA.UpdateAppDetail(appCode, subCode, ddl.SelectedValue, Today.Date)
End If
If strErr = "" Then
lblError.Text = msgClass.successMsg(subCodeName, "1")
Else
lblError.Text = msgClass.ErrorMsg(subCodeName, "1")
End If
dgResult.DataSource = appDetailDBA.getDataClassification(empID, txtSearch.Text)
dgResult.DataBind()
End Sub
Function UpdateAppDetail(ByVal appCode As String, ByVal subCode As String, ByVal classType As String, ByVal classEffDte As String)
Dim strErr As String = ""
Dim con As New SqlConnection(kiosk_loginConnStr)
con.Open()
Try
Dim sqlCommand As SqlCommand = con.CreateCommand()
Dim sql As String = "Update AppDetail SET ClassificationType = '" + classType + "', ClassificationEffDate = '" + classEffDte + "' WHERE AppCode = '" + appCode + "'" & _
" AND SubCode = '" + subCode + "'"
sqlCommand.CommandText = sql
sqlCommand.ExecuteNonQuery()
Catch ex As Exception
strErr = ex.Message
Finally
con.Close()
End Try
Return strErr
End Function
2 Answers
What type of database are you using? Do you commit the changes to the database?
[Update (from discussion below)] It appears that VB automatically commits all commands unless you explicitly tell it not to, so that's not the problem.
[Update 2] My working theory is that the database is configured incorrectly, as in ExecuteNonQuery() Not Working
Another possibly explaination could be this: http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/dbbf8025-9f53-4862-8705-62a106fe2114
13 Comments
My suggestion would be to try running sqlCommand.Commit(), this "should" stash any changes you have made on the database, into the actual database. Please note, my actual "command" might be off, but the idea is there. If you can commit on the sql command, try committing on the connection level.
{ }) on the editor toolbar to nicely format and syntax highlight it!