my program : When i enter a name in the textfiled and click on search i should get that name along with its ID listed below in my data grid and if such name does not exists i should get msg "enquiry not found"...
Am getting the result however not excatly....after 1st entry even if the name exists in database i get msg "enquiry not found" and the enquiry along with id gets listed in the datagrid.
PLZ CORRECT MY CODE FOR THE SAME

Secondly for each entry of name i want data grid to be refreshed....how to do it ??? plz let me know soon........ am wating......plzzzzzzzz

cua
Rohan

Private Sub checkenq()

        dbadapter = New OleDbDataAdapter("select  eid 'Enquiry ID' ,vname 'Name' ,vMobno 'Mobile No' from tblenquiry where vname = '" & (txtname.Text) & "'", connectionstring)
        dbadapter.Fill(dtenquiry)
        If txtname.Text = dtenquiry.Rows(0).Item(1) Then
            MsgBox("Enquiry Exists")
            dgenqrec.DataSource = dtenquiry
            cmdfound.Enabled = True
        Else

            MsgBox("Enquiry Not Found, Kindly Fill the Enquiry Form")

        End If

See this example :

Private Sub checkenq()
        Dim cmdTest As New OleDb.OleDbCommand
        Dim daTest As New OleDb.OleDbDataAdapter
        Dim dsTest As New DataSet
        Dim dtTest As New DataTable
        conn = GetConnect()
        Try
            conn.Open()
            cmdTest = conn.CreateCommand
            cmdTest.CommandText = "SELECT * FROM Customer where IDCustomer = '" & Trim(txtId.Text) & "'"
            daTest.SelectCommand = cmdTest
            daTest.Fill(dsTest, "Customer")
            dtTest = dsTest.Tables(0)
            If (dtTest.Rows.Count) > 0 Then
                MsgBox("Enquiry Exists")
                dgenqrec.DataSource = dsTest
                dgenqrec.DataMember = "Customer"
                dgenqrec.ReadOnly = True
                'cmdfound.Enabled = True
            Else
                MsgBox("Enquiry Not Found, Kindly Fill the Enquiry Form")
            End If
            conn.Close()
        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Koneksi Error !!")
        End Try
    End Sub
This article has been dead for over six months. Start a new discussion instead.