0
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....

Attachments a.jpg 49.34 KB
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Pgmer
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.