954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Updating error with DataAdapter in vb.net

0
By Ujjval Pankajkumar Dave on Aug 17th, 2010 1:04 am

i had tried on this code,but when this code is in running mode it will update all rows in database. I want to update specific row in database.
please somebody help to solve this problem.

Dim conmenots As New OleDbConnection(connstri)
try
             Dim myint As Integer = lbl_auto.Text
            Dim dtps As String = dtp_dob.Value.ToShortDateString               
           If conmenots.State = ConnectionState.Closed Then
                    conmenots.Open()
           End If
            Dim oledbAdapter As New OleDbc
            Dim sql As String = "Update id_detail set fnm='" & txt_fname.Text & "', lnm='" & txt_lname.Text & "', address='" & txt_add1.Text & "', zcode='" & txt_zipcode.Text & "', city='" & txt_city.Text & "', state='" & txt_state.Text & "', country='" & txt_country.Text & "', ssn='" & txt_ssn.Text & "', vtraffic='" & txt_visitortraffic.Text & "', website='" & txt_website.Text & "', email='" & txt_email.Text & "', emailpass='" & txt_pass.Text & "', aimid='" & txt_aiminfo.Text & "', aimpass='" & txt_aim_pass.Text & "', skyid='" & txt_skyup.Text & "', skypass='" & txt_sky_pass.Text & "', emaillink='" & txt_emaillink.Text & "', ph='" & txt_phno.Text & "', decweb='" & txt_dwebsite.Text & "', comment='" & txt_comment.Text & "', dob='" & dtps & "', cpaid='" & txt_cpa_id.Text & "', cpapass='" & txt_cpa_pass.Text & "' WHERE no = '" & lbl_auto.Text & "' "

           oledbAdapter.UpdateCommand = conmenots.CreateCommand
           oledbAdapter.UpdateCommand.CommandText = sql
           ivallues = oledbAdapter.UpdateCommand.ExecuteNonQuery()
           MsgBox("Row(s) Updated !! ")
           If ivallues > 0 Then
                    MsgBox("DATA UPDATED", MsgBoxStyle.Information)
                    ivalues = 0
                    Call update_file()
                    Call ClearTextBox(Me)
                    Call no_count()
           Else
                    MsgBox("update failed", MsgBoxStyle.Critical)
           End If
 Catch ex As Exception
            MessageBox.Show(ex.Message & " - " & ex.Source)
        End Try
        Button3.Show()
        btn_update_record.Hide()
    End Sub

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You