Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Queries for Datagrid View in VB 2008

Queries for Datagrid View in VB 2008

Scheduled Pinned Locked Moved Visual Basic
databasequestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Razanust
    wrote on last edited by
    #1

    Can we use the text of a textbox as a query filter in VB? If yes how?

    S 1 Reply Last reply
    0
    • R Razanust

      Can we use the text of a textbox as a query filter in VB? If yes how?

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      Yes you want to have a look at the dataview class. assuming you have data loaded into a datatable, this example i use from the changing of the date in a datetimepicker

      dim dv as dataview
      dv = new dataview(dt)

      Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
      ' MessageBox.Show(DateTimePicker1.Text)
      dv.RowFilter = "duedate = '" & DateTimePicker1.Text & "'"
      End Sub

      Thanks for taking the time, now go away and grow up and return in a newer, more polite and less shouty and ignorant form. - Dalek Dave

      R 1 Reply Last reply
      0
      • S Simon_Whale

        Yes you want to have a look at the dataview class. assuming you have data loaded into a datatable, this example i use from the changing of the date in a datetimepicker

        dim dv as dataview
        dv = new dataview(dt)

        Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        ' MessageBox.Show(DateTimePicker1.Text)
        dv.RowFilter = "duedate = '" & DateTimePicker1.Text & "'"
        End Sub

        Thanks for taking the time, now go away and grow up and return in a newer, more polite and less shouty and ignorant form. - Dalek Dave

        R Offline
        R Offline
        Razanust
        wrote on last edited by
        #3

        I wanted to ask this way. I have a query for my data grid view as: SELECT ID, Name, City, Fee, Technology FROM [uni list] WHERE (Name = 'Data') where data is used as a string and this works fine BUT.. When i refer the filter case to a textbox it doesn't work. It takes this whole thing as a string and not producing the desired results. SELECT ID, Name, City, Fee, Technology FROM [uni list] WHERE (Name = '[text].textbox1') How can this be resolves

        S 1 Reply Last reply
        0
        • R Razanust

          I wanted to ask this way. I have a query for my data grid view as: SELECT ID, Name, City, Fee, Technology FROM [uni list] WHERE (Name = 'Data') where data is used as a string and this works fine BUT.. When i refer the filter case to a textbox it doesn't work. It takes this whole thing as a string and not producing the desired results. SELECT ID, Name, City, Fee, Technology FROM [uni list] WHERE (Name = '[text].textbox1') How can this be resolves

          S Offline
          S Offline
          Simon_Whale
          wrote on last edited by
          #4

          how do you get your data to the grid? is it via a dataset or datatable? if datatable then this bit goes in the event that loads your grid

          dim myDataView as new dataview(myDataTable)

          Datagridview1.datasource = myDataview

          if Dataset then

          dim myDataview as new dataview(myDataset.tables(0))
          Datagridview1.datasource = myDataview

          but the filtering is the same how ever this bit goes in what you use to fire the filtering, i prefer to use a button to allow filetering

          myDataView.Filter = "[Name] = '" & yourTextBox.text & "'"

          if you need more help i would need to see your vb.net code as that is where its done and not at the sql statement. Simon

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups