from my this code for search record..
what code for update after i search the record?
anyone can help me?

Private Sub btnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCari.Click

        Dim ConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=""H:\PROJEK\New Sistem\SISTEM_DATABASE.mdb"";"
        ' string declare connection ke dbase
        Dim DBCon As New OleDb.OleDbConnection(ConString)
        Dim g_login As String
        ' global decalration
        g_login = Me.txtNoIC.Text

        If g_login = "" Then
            MessageBox.Show("Isi Nombor Kad Pengenalan terlebih dahulu", "Log Masuk", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Me.txtNoIC.Focus()
            Return
        End If

        Dim strsql As String = "SELECT * FROM RekodAnggaran WHERE [NoIC]='" & txtNoIC.Text & "'"
        Dim cmd As New OleDb.OleDbCommand(strsql, DBCon)
        Dim dr As OleDb.OleDbDataReader
        Dim valid As Boolean = False
        Dim HasRows As Boolean = False
        Try
            DBCon.Open()
            dr = cmd.ExecuteReader
            If dr.HasRows Then
                While dr.Read
                    If g_login = dr.Item("NoIC") Then
                        valid = True
                        txtNama.Text = dr.Item("Nama")
                        txtTarikhLahir.Text = dr.Item("TarikhLahir")
                        DTPMI.Value = dr.Item("TarikhMI")
                        txtAlamat.Text = dr.Item("Alamat")
                        txtNoTelefon.Text = dr.Item("NoTelefon")
                        cmbPremium.Text = dr.Item("Umur")
                        cmbPelan.Text = dr.Item("Pelan")
                        cmbJPembayaran.Text = dr.Item("JPembayaran")
                        txtPremium.Text = dr.Item("PremiumTahunan")
                        txtPremiumJP.Text = dr.Item("PremiumJP")
                        cmbStatus.Text = dr.Item("Status")
                    End If
                End While
                HasRows = True
            Else
                txtNama.Clear()
                txtNoIC.Clear()
                txtTarikhLahir.Clear()
                DTPMI.ResetText()
                txtAlamat.Clear()
                txtNoTelefon.Clear()
                cmbPremium.Text = ""
                cmbPelan.Text = ""
                cmbJPembayaran.Text = ""
                txtPremium.Text = ""
                txtPremiumJP.Text = ""
                cmbStatus.Text = ""
                MessageBox.Show("No Kad Pengenalan yang dimasukkan tiada di dalam rekod", "Carian Rekod", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
            dr.Close()
        Catch exO As OleDb.OleDbException
            MessageBox.Show(exO.Message)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            If DBCon.State = ConnectionState.Open Then
                DBCon.Close()
            End If
            cmd = Nothing
            dr = Nothing
            DBCon.Dispose()
            GC.Collect()
        End Try

    End Sub

Why not just use a typed dataset to run the update for you? You had a dataset in the project.

Also never call GC.Collect() from code. It doesn't do what you want, ever, and you will suffer a performance penalty anyways.

sknake...
how to call dataset to update?

Dim cmd as new OleDBCommand()
cmd.Connection=DBCon
cmd.CommandText="update TableName set NumCol=?,NameCol=? where PK_Col=?"
cmd.Parameters.Add(New OleDbParameter("?", OleDbType.Integer, 4)).Value = 10
cmd.Parameters.Add(New OleDbParameter("?", OleDbType.VarChar, 40)).Value = "Mr.A"
cmd.Parameters.Add(New OleDbParameter("?", OleDbType.Integer, 4)).Value = 1

DBCon.Open()
cmd.ExecuteNonQuery()
DBCon.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.