Member_2_4286571
asked on
Fill tableAdapter with selected data only
Hello experts,
I would like to fill datagrid with data filtered by date. I can fill all the data into tableadapter and then use filter, but i would like to avoid that since after a while there is lot's of data and everything start to slow down.
currently i am using Me.TableAdapter.Fill(Me.db _data.Date s), is there simple way to pull only selected data from database and ignoring the rest.
For example Me.TableAdapter.Fill(Me.db _data.Date s, "20110302") or something like that.
Thank you!
I would like to fill datagrid with data filtered by date. I can fill all the data into tableadapter and then use filter, but i would like to avoid that since after a while there is lot's of data and everything start to slow down.
currently i am using Me.TableAdapter.Fill(Me.db
For example Me.TableAdapter.Fill(Me.db
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have found on MSDN forums something that may help with this, but since i am still new to vb.net i will need some help from you guys.
This code below should go into dataset code.
-------------------------- ---------- ---------- -
Namespace myDataSetTableAdapters
Partial Class myTableAdapter
Public ReadOnly Property selectcommand() As System.Data.SqlClient.SqlC ommand
Get
Return Me.CommandCollection(0)
End Get
End Property
End Class
End Namespace
-------------------------- ---------- ---------- ----
In your code, you can now set the select command via the following line:
Me.myTableAdapter.selectco mmand.Comm andText = "select * from table"
I tried this but i am getting "CommandCollection is not a member of mydatasettableadapters..." error at this part of the code "Return Me.CommandCollection(0)"
Forum thread where i found this is:MSDN Forums
Am I on the right track with this one?
This code below should go into dataset code.
--------------------------
Namespace myDataSetTableAdapters
Partial Class myTableAdapter
Public ReadOnly Property selectcommand() As System.Data.SqlClient.SqlC
Get
Return Me.CommandCollection(0)
End Get
End Property
End Class
End Namespace
--------------------------
In your code, you can now set the select command via the following line:
Me.myTableAdapter.selectco
I tried this but i am getting "CommandCollection is not a member of mydatasettableadapters..."
Forum thread where i found this is:MSDN Forums
Am I on the right track with this one?
ASKER
Ok i solved this in different way.
In TableAdapter i added new query "SELECT Date,Brrac... FROM dbo.data where Date=@Date" and saved as FillByDate.
then in my code i call Me.TableAdapter.Fill(Me.db _data.Date s, dtpDate.value.date)
dtpDate is datetimepicker.
This works perfectly, but now how would i construct this to load selection between two different dates.
Lets say I have dtpDate1 and dtpDate2. Now I want to construct query so it will show only dates that are equal to dtpDate1 and dtpDate2, and dates between.
Thanks for all assistance so far.
In TableAdapter i added new query "SELECT Date,Brrac... FROM dbo.data where Date=@Date" and saved as FillByDate.
then in my code i call Me.TableAdapter.Fill(Me.db
dtpDate is datetimepicker.
This works perfectly, but now how would i construct this to load selection between two different dates.
Lets say I have dtpDate1 and dtpDate2. Now I want to construct query so it will show only dates that are equal to dtpDate1 and dtpDate2, and dates between.
Thanks for all assistance so far.
ASKER
edit:
small typo in: "Me.TableAdapter.FillByDate(Me.db_data.Dates, dtpDate.value.date)"
small typo in: "Me.TableAdapter.FillByDate(Me.db_data.Dates, dtpDate.value.date)"
ASKER
I am playing with few different solutions, will post here solution that worked for me.