?
Solved

Dynamic STRONGLY Typed Dataset Queries

Posted on 2009-05-20
6
Medium Priority
?
732 Views
Last Modified: 2013-11-26
How do I run a query like this:

Dim dbC As New SqlCommand("SELECT Stat" & Stat.SurvNo & " FROM eV67Survey WHERE uid = " & uid, conn0)
conn0.Open() : ThisResp = dbC.ExecuteScalar() : conn0.Close()

Using Strongly Typed Datasets?

(Is it even possible?)
0
Comment
Question by:Espavo
[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
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24441200
1) I don't know if it it possible.

2) I don't understand why you would want to do that?

3) You can easily run that kind of query outside of the typed DataSet, so it is starting to sound like trying to fit a square peg in a round hole (which you can do with a really big hammer!!).
0
 
LVL 10

Author Comment

by:Espavo
ID: 24441511
2) The reason I would want to do it is 'cause my code using datasets is so much cleaner and more efficient than when using SqlCommands...
3) I'm aware of that... and that's why I was wondering if there may be a different way to do it...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24446352
Do you want to use the QueryAdapter, and extend the typed DataSet class to use dynamic queries?
0
Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

 
LVL 10

Author Comment

by:Espavo
ID: 24448021
Seems like I'm barking up a tree... (not sure what a QueryAdaptor is...)
What I'd like to be able to do is replace this:
for i = 1 to 200
Dim dbC As New SqlCommand("SELECT Stat" & i & " FROM eV67Survey WHERE uid = " & uid, conn0)
conn0.Open() : ThisResp = dbC.ExecuteScalar() : conn0.Close()
next
With something like this:
Dim SurvAdaptor As New SQLDataSetTableAdapters.SurveyTableAdapter
for i = 1 to 200
ThisResp = SurvAdaptor.GetStatValue("Stat" & Stat.SurvNo,uid)
next
The DataSet would need to look something like:
SELECT @StatNo FROM eV67Survey WHERE uid = @uid

Thanks, Gayo
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 24450356
Here is a great article from Scott Guthrie, that talks about typed DataSets.

Building a DAL using Strongly Typed TableAdapters and DataTables in VS 2005 and ASP.NET 2.0
http://weblogs.asp.net/scottgu/archive/2006/01/15/435498.aspx

If you use the <Add Query> option from the designer, and create a query, then the designer generates a QueryTableAdapter that you can use to execute queries.
0
 
LVL 10

Author Closing Comment

by:Espavo
ID: 31583689
Thanks... the link above has given me a lot to think about (most of it I know and use already...) I'll follow some of the links from there and see if I have any other luck... (Doesn't look like I'll be getting lucky soon though...)
0

Featured Post

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

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