why my coding find data only can find 1 data, then can't find any other data. if i want find other i need restart my vb.net..
what the problem anyone can help me please?

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

        sql = ("SELECT * FROM RekodAnggaran WHERE [NoIC]='" & txtNoIC.Text & "'")

        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "RekodAnggaran")

        If ds.Tables("RekodAnggaran").Rows.Count < 1 Then
            MsgBox("Nombor IC yang dimasukkan tiada didalam rekod.")
            txtNoIC.Clear()
        Else
            txtNama.Text() = ds.Tables("RekodAnggaran").Rows(0).Item("Nama")
            cmbPremium.Text = ds.Tables("RekodAnggaran").Rows(0).Item("Umur")
            txtAlamat.Text = ds.Tables("RekodAnggaran").Rows(0).Item("Alamat")
            txtTarikhLahir.Text = ds.Tables("RekodAnggaran").Rows(0).Item("TarikhLahir")
            txtTarikhMI.Text = ds.Tables("RekodAnggaran").Rows(0).Item("TarikhMI")
            cmbPelan.Text = ds.Tables("RekodAnggaran").Rows(0).Item("Pelan")
            txtNoTelefon.Text = ds.Tables("RekodAnggaran").Rows(0).Item("NoTelefon")
            cmbJPembayaran.Text = ds.Tables("RekodAnggaran").Rows(0).Item("JPembayaran")
            lblPremium.Text = ds.Tables("RekodAnggaran").Rows(0).Item("PremiumTahunan")
            lblPremiumJP.Text = ds.Tables("RekodAnggaran").Rows(0).Item("PremiumJP")
        End If



    End Sub

yes because you should do an for each loop on the records.

what u mean?
can u show me example coding or help me fix my coding?
please?

numrows = ds.Tables("RekodAnggaran").Rows.Count

            For x = 0 To numrows - 1

             txtNama.Text() = ds.Tables("RekodAnggaran").Rows(0).Item("Nama")
            cmbPremium.Text = ds.Tables("RekodAnggaran").Rows(0).Item("Umur")
            txtAlamat.Text = ds.Tables("RekodAnggaran").Rows(0).Item("Alamat")
            txtTarikhLahir.Text = ds.Tables("RekodAnggaran").Rows(0).Item("TarikhLahir")
            txtTarikhMI.Text = ds.Tables("RekodAnggaran").Rows(0).Item("TarikhMI")
            cmbPelan.Text = ds.Tables("RekodAnggaran").Rows(0).Item("Pelan")
            txtNoTelefon.Text = ds.Tables("RekodAnggaran").Rows(0).Item("NoTelefon")
            cmbJPembayaran.Text = ds.Tables("RekodAnggaran").Rows(0).Item("JPembayaran")
            lblPremium.Text = ds.Tables("RekodAnggaran").Rows(0).Item("PremiumTahunan")
            lblPremiumJP.Text = ds.Tables("RekodAnggaran").Rows(0).Item("PremiumJP")


            Next x

something like this (not tested):

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

        sql = ("SELECT * FROM RekodAnggaran WHERE [NoIC]='" & txtNoIC.Text & "'")
        da = New OleDb.OleDbDataAdapter(sql, con)
        Dim ds As New DataSet
        Dim dt As DataTable, row As DataRow
        da.Fill(ds)
        dt = ds.Tables("RekodAnggaran")
       
        If ds.Tables("RekodAnggaran").Rows.Count < 1 Then
            MsgBox("Nombor IC yang dimasukkan tiada didalam rekod.")
            txtNoIC.Clear()
            Return
       end if

dim i as integer =0
For each row in dt.Rows()
            txtNama.Text() = ds.Tables("RekodAnggaran").Rows(i).Item("Nama")
            cmbPremium.Text = ds.Tables("RekodAnggaran").Rows(i).Item("Umur")
            txtAlamat.Text = ds.Tables("RekodAnggaran").Rows(i).Item("Alamat")
            txtTarikhLahir.Text = ds.Tables("RekodAnggaran").Rows(i).Item("TarikhLahir")
            txtTarikhMI.Text = ds.Tables("RekodAnggaran").Rows(i).Item("TarikhMI")
            cmbPelan.Text = ds.Tables("RekodAnggaran").Rows(i).Item("Pelan")
            txtNoTelefon.Text = ds.Tables("RekodAnggaran").Rows(i).Item("NoTelefon")
            cmbJPembayaran.Text = ds.Tables("RekodAnggaran").Rows(i).Item("JPembayaran")
            lblPremium.Text = ds.Tables("RekodAnggaran").Rows(i).Item("PremiumTahunan")
            lblPremiumJP.Text = ds.Tables("RekodAnggaran").Rows(i).Item("PremiumJP")
            i+=1
next

    End Sub

kind of

geek i use u code..
but got error

Object reference not set to an instance of an object.

at this code

If ds.Tables("RekodAnggaran").Rows.Count < 1 Then

anybody can help me please?

did you try to debug it?
check if ds is something.

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.