[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need help accessing Stored Query

Posted on 2014-07-13
2
Medium Priority
?
313 Views
Last Modified: 2014-07-14
Hello,

I'm a VB.net beginner.  

My project has a Data Source called On_OrderDataSet which works great.  I'm able to access objects in this data source using code like this:
Dim dtCustomer As DataTable = On_OrderDataSet.Tables("Tbl_Customers")

Open in new window


So, I added a stored parameter-ized query, named Qry_Customers, using the Add option in the .xsd file.  Screenshot shows it.  Problem is that I can't figure out how to use Qry_Customers in my code.  I'd like to do something like:
Dim dtCustomer As DataTable = On_OrderDataSet.Queries("Qry_Customers")

Open in new window

 But it doesn't work.
Screenshot of Data Sources and QueriesTableAdapaterHow do I do fill a DataTable or DataRow object using Qry_Customers?  Code would be helpful.
Thanks,
Jason
0
Comment
Question by:SqueezeOJ
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 40193959
The QueriesTableAdapter is intended more for executing scalar queries, or performing UPDATE/INSERT/DELETE operations.

Instead you should be adding your query to the existing Tbl_CustomersTableAdapter. That will then allow you to create a GetDataBy... method, which you can use in the same way as the existing GetData() method, only you'll have the addition of being able to pass a parameter to it.

Which would then allow you to do something like:
Dim adap As New DataSet1TableAdapters.CustomerTableAdapter
Dim table As DataSet1.CustomerDataTable = adap.GetDataByLastName("smith")

Open in new window

0
 

Author Closing Comment

by:SqueezeOJ
ID: 40194726
Thanks!

I simply recreated the "query" using the same SQL through the Add --> Table Adapter wizard in the .xsd area.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

834 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