Queries for Datagrid View in VB 2008
-
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 SubThanks 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
-
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 SubThanks 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
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
-
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
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 = myDataviewbut 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