Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Fill tableAdapter with selected data only

Posted on 2011-03-01
6
Medium Priority
?
2,748 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

598 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