?
Solved

Fill tableAdapter with selected data only

Posted on 2011-03-01
6
Medium Priority
?
2,678 Views
Last Modified: 2012-05-11
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.Dates), is there simple way to pull only selected data from database and ignoring the rest.

For example  Me.TableAdapter.Fill(Me.db_data.Dates, "20110302") or something like that.

Thank you!
0
Comment
Question by:Grogel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 7

Accepted Solution

by:
EYoung earned 1000 total points
ID: 35019019
There is a way to pass a parameter to the TableAdapter in the DataSet but I have not figured out how to change the value of the parm at execution time.  You can find the select property and parm property in the DataSet in your project.  Just click at the top right to show all files, then click on the specific dataset and look at its properties.  Best of luck.
0
 
LVL 1

Assisted Solution

by:rayraymp
rayraymp earned 1000 total points
ID: 35088443
What database are you accessing?  Is it local or served?  If you're using an sqlConnector or an OdbcConnector, you may consider reducing the number of fields displayed, or as you said, the number of records.  In the SQL, its pretty easy to do by changing the query.  
0
 

Author Comment

by:Grogel
ID: 35091845
I am accessing both, local and served depends on situation however with local i have no problem, but when acessing database over internet connection slowdowns are noticable.

I am playing with few different solutions, will post here solution that worked for me.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Grogel
ID: 35137305
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.SqlCommand
            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.selectcommand.CommandText = "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?

0
 

Author Comment

by:Grogel
ID: 35138010
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.Dates, 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.



0
 

Author Comment

by:Grogel
ID: 35138039
edit:

small typo in: "Me.TableAdapter.FillByDate(Me.db_data.Dates, dtpDate.value.date)"
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question