Solved

Fill tableAdapter with selected data only

Posted on 2011-03-01
6
2,538 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
  • 4
6 Comments
 
LVL 7

Accepted Solution

by:
EYoung earned 250 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 250 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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