locked
vb.net update code RRS feed

  • Question

  • i have written an update code in vb.net, that should update user records in sql server, the problem is when i click on update button in vb.net the records is updated, when i check the sql server table i discovered that the update is affecting the other rows too!!!

    below is my code in vb.net 

    Try Select Case MsgBox("User Details are Going to be Updated,are You Sure of this Action?", MsgBoxStyle.YesNo, "Update") Case MsgBoxResult.Yes cn.Open() query = New SqlCommand("Update ManageUsers set Fname = '" & FnameTextBox.Text & "',

    Lname = '" & LnameTextBox.Text & "',

    DOB = '" & DOBDateTimePicker.Value.Date & "', Passport = '" & PassportTextBox.Text & "',

    Adress = '" & AddressRichTextBox.Text & "', UserName = '" & UserNameTextBox.Text & "',

    Passcode = '" & PasswordTextBox.Text & "', Shift = '" & ShiftTypeComboBox.Text & "',

    Gender = '" & GenComboBox.Text & "', Position = '" & PosiComboBox.Text & "' ") query.Connection = cn query.ExecuteNonQuery() MsgBox("User Details have been Updated") Case MsgBoxResult.No End Select Catch ex As Exception MsgBox(ex.Message) End Try cn.Close()





    • Edited by htm7 Friday, October 31, 2014 3:52 AM
    • Moved by Olaf HelperMVP Friday, November 14, 2014 7:55 PM Moved from "Database Engine" to a more specific forum for a better response.
    Friday, October 31, 2014 3:48 AM

Answers