Skip navigation links

MySQL Forums :: Connector/NET and C#, Mono, .Net :: VB .NET Update Command Inserts NULL


Advanced Search

VB .NET Update Command Inserts NULL
Posted by: David Rose ()
Date: December 08, 2004 10:06PM

I've got a bit of a problem. When I run the following code, it over-writes the record in the database with NULL. I'm not sure what I'm doing wrong, but it seems that all of the values that are included in the UPDATE command are being over-written.

Below is the code that calls the UPDATE command:

Private Sub dgUserList_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgUserList.UpdateCommand
Dim intRightsID As Integer = CType(e.Item.FindControl("lblRightsID"), Label).Text
Dim strRightsUser_Edit As String = CType(e.Item.FindControl("txtRightsUser_Edit"), TextBox).Text
Dim intRightsApplication_Edit As Integer = CType(e.Item.FindControl("ddlRightsApplication_Edit"), DropDownList).SelectedValue
Dim blnRightsAdd_Edit As Boolean = CType(e.Item.FindControl("chkRightsAdd_Edit"), CheckBox).Checked
Dim blnRightsEdit_Edit As Boolean = CType(e.Item.FindControl("chkRightsEdit_Edit"), CheckBox).Checked
Dim blnRightsDelete_Edit As Boolean = CType(e.Item.FindControl("chkRightsDelete_Edit"), CheckBox).Checked
Dim blnRightsAdmin_Edit As Boolean = CType(e.Item.FindControl("chkRightsAdmin_Edit"), CheckBox).Checked
Dim strSQL As String = "UPDATE user_access.user_access_rights SET rights_user = @RightsUser, rights_app_id = @RightsApplication, rights_add = @RightsAdd, rights_edit = @RightsEdit, rights_delete = @RightsDelete, rights_admin = @RightsAdmin WHERE rights_id = " & intRightsID
Dim dbConnection As Odbc.OdbcConnection = New Odbc.OdbcConnection(strConnectionString)
Dim dbCommand As Odbc.OdbcCommand = New Odbc.OdbcCommand(strSQL, dbConnection)
With dbCommand.Parameters
.Add(New Odbc.OdbcParameter("@RightsUser", Odbc.OdbcType.VarChar, 50)).Value = strRightsUser_Edit
.Add(New Odbc.OdbcParameter("@RightsApplication", Odbc.OdbcType.Int, 11)).Value = intRightsApplication_Edit
.Add(New Odbc.OdbcParameter("@RightsAdd", Odbc.OdbcType.TinyInt, 1)).Value = blnRightsAdd_Edit
.Add(New Odbc.OdbcParameter("@RightsEdit", Odbc.OdbcType.TinyInt, 1)).Value = blnRightsEdit_Edit
.Add(New Odbc.OdbcParameter("@RightsDelete", Odbc.OdbcType.TinyInt, 1)).Value = blnRightsDelete_Edit
.Add(New Odbc.OdbcParameter("@RightsAdmin", Odbc.OdbcType.TinyInt, 1)).Value = blnRightsAdmin_Edit
End With
Try
dbConnection.Open()
dbCommand.ExecuteNonQuery()
Catch ex As Exception
DisplayError(ex)
Finally
dbConnection.Close()
End Try
dgUserList_CancelCommand(Nothing, Nothing)
End Sub

And the results:

| 3 | NULL | 1 | NULL | NULL | NULL | NULL | NULL |

Suggestions would be greatly appreciated.

Options: ReplyQuote


Subject Written By Posted
VB .NET Update Command Inserts NULL David Rose 12/08/2004 10:06PM
Re: VB .NET Update Command Inserts NULL Marius Leonard 12/22/2004 01:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.