Wednesday, April 6, 2011

VB.NET: Use a Textbox to filter Data

Here is my code:

Dim connectionString As String ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\ACCESS DATABASE\search.mdb"

Dim selectCommand As String
Dim connection As New OleDbConnection(connectionString)

selectCommand = "select * from GH  WHERE (COURSE='BSIT')"
Me.dataAdapter = New OleDbDataAdapter(selectCommand, connection)

I want to know how to use a textbox to filter data. Because this code will have to enumerate all of the courses, and will need much buttons.

From stackoverflow
  • No sure I understand the question correct. Try this

    selectCommand = "select * from GH  WHERE (COURSE='" & TextBox1.Text & "')"
    

    Also you need to avoid single quotes(') on the textbox.

    : thanks!it works
    Anuraj : Mark it as answer, if you got the solution.
    David-W-Fenton : Er, @Remou, is the caveate about the .Text property applicable in VB.NET, which is the programming environment here? It *is* relevant within Access/VBA, but I wouldn't assume it would be in VB.NET, as in VB6 and before, the .Text property was equivalent to the Access .Value property (so far as I understand VB forms programming).

0 comments:

Post a Comment