Using dataset queries in tableadapters

jswota

Well-known member
Joined
Feb 23, 2009
Messages
49
Programming Experience
Beginner
Hi.

I doubt this is possible but i think it would be really useful.

Is it possible to use a dataset query within a tableadapter? Similar to the way you would use a stored procedure or function within a sql query. For instance, if i create a query that gives me a total weight for a packing slip based on the packing slip ID, can i use this result when creating a new tableadapter.

Something like:

Select ID, ShipTo, ShipBy, ShipDate, ds_PackingSlips.GetPackingSlipWeight(ID) as ShipWeight
From PackingSlips

Thanks for the help.
 
The queries in a TableAdapter ARE SQL queries. It's just SQL code that gets executed on the database, just like any other. It's not executed at the client so client methods mean nothing.
 
Thanks. I was hoping that there was some trick to grab the result of query and use it in the tableadapter. Would be nice to see something like this in ado.

i knew it was a long shot.

Thanks again.
 
Thanks. I was hoping that there was some trick to grab the result of query and use it in the tableadapter. Would be nice to see something like this in ado.

i knew it was a long shot.

Thanks again.
It's not going to happen and why would it? If you want to put the result of some VB code into the SQL then you put a parameter into the SQL and set the value of that parameter from the result of your VB code. What you're suggesting would require a huge reworking of the way DbCommands work for essentially no gain.
 
If you want to put the result of some VB code into the SQL ...

I am not exactly trying to put the result of VB code into SQL.

Let's just say that you were writing a stored procedure in a SQL database. For whatever reason you have created various functions. These functions are used within the stored procedure you just created.

Now let's say that you don't have write access to SQL and can't do anything i just said.
...and why would it?
I would like to be able to do the exact same thing in ADO.

Do you know if this is possible?

A lot of people like to do all of their querying in the database. ADO allows you to create queries using these existing stored procedures. Why did they implement the functionality of creating SQL queries from scratch in ADO? Was it just so people didn't have to create the queries in the database? Or people didn't have write access to the database? For whatever reason it seems like they should have put the same functionality in ADO that is available in SQL.

Thanks for your help.
 
I think you misunderstand what's going on. ADO.NET (which is quite different to ADO) allows you to write SQL code in your app, but that SQL code still gets executed on the database. You can't put VB code into that SQL code because the SQL code is executed on the database and the database knows nothing about VB. If you want functions in your VB app then you write them in VB. You can then insert the result into your SQL if you so desire.

ADO.NET is not magic. ADO.NET can only do what the database allows it to do. They can't add functionality to ADO.NET that isn't permitted by the database.
 
Back
Top