Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim asm As String
        asm = ComboBox2.Text
        cmdOLEDB.CommandText = "SELECT * FROM sale "
        cmdOLEDB.Connection = cnnOLEDB
        Dim ab = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")
        Dim dr = cmdOLEDB.ExecuteReader

        Do While dr.Read
            v1 = dr.Item("NAME")
            If (asm = v1) Then
                pa = v1.ToString
                Dim v3 = dr.Item("EDATE")
                Dim v4 = dr.Item("EXPDATE")
                Dim v5 = dr.Item("STOCK")
                v6 = dr.Item("RATE")
                v2 = dr.Item("ID")

                txtedate.Text = v3
                txtexpdate.Text = v4
                txtstock.Text = v5
                txtrate.Text = v6
                txtid.Text = v2
                If DateTime.Compare(ab, v4) = 0 Then
                    txtexpdate.BackColor = Color.Red
                End If

            End If
        Loop
    End Sub

i choose one record from combo box... that is bind from name after that when i select another it gives error there is and already data associated.. please send me some solution....

you need to initialize the cmdOLEDB using new keyword
like cmdOLEDB=new oledbcommand. And after performing action please dispose the objects like coonection object and coomand object.

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.