0 down vote favorite

I have a problem, what i want is when the user enters data in the textbox, it needs to compare the entered textbox value like ,,name, with value ,,name,, in dataset.

If name exists, It should enter the value in textbox. If not, it should pop up a message box asking user to add new value (name).

I only have code how to fill dataset. Because I do not know where and how to begin.I hope you understand me. Im using vb.net and sql server 2008.

 Public Function gatherSelect()
    Main.con.Close()
    Main.con.Open()
    exe = "basicGatherSelect"
    Dim startTrasaction = Main.con.BeginTransaction

    Try


        com = New SqlCommand(exe, Main.con)
        com.CommandType = CommandType.StoredProcedure



        com.Transaction = startTrasaction
        adp.SelectCommand = com


        adp.Fill(sqlDS)

        adp.Dispose()
        com.Dispose()



        startTrasaction.Commit()

        GridControl1.DataSource = sqlDS.Tables(0)          
        Main.con.Close()!


    Catch ex As Exception
        startTrasaction.Commit()
        MessageBox.Show(ex.Message)

    Finally

        txtName.Text = ""
        txtStateID.Text = ""



    End Try

End Function

The best way to do it is to fill your dataset "sqlDS" into a dataview then you can filter the dataview using the rowfilter method.
Ex:
Dim DV as new DataView
DV.table=sqlDS.tables(0)
GridControl1.DataSource =DV
DV.RowFilter = "name = '" & me.textbox1.text & "'

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.