Solved

Fill tableAdapter with selected data only

Posted on 2011-03-01
6
2,618 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 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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