Data Source, stored proc vs. query.

SteveInBeloit

Well-known member
Joined
May 22, 2006
Messages
132
Programming Experience
10+
Hi,
I added a data source to my project, hooked it to an SQL Server database. When I look at the Data Source tab, I can see my tables, and use them. I also see *some* of my stored procs. When I go into Dataset designer, I see the tables, and some of the stored procs. I can see the rest of the stored procs all in one window called QueriesTableAdapter. What made them go here and not like the others? Also, I want to base DataGridViews off of these, but they are not in the Data Sources tab for me to drag over.

Assuming that I can drag them over and use them in DataGridViews, can I pass parameters?

Thanks
 
whatever wizard designed those datasets, couldnt accurately determine what(if any) tables those sprocs (in QueriesTableAdapter) used.. I'd guess if the proc doesnt return a cursor to an existing table, it cannot be guessed to be associated with that table. You can do it manually simply by right clicking whichever tableadapter you want the query in, Add Query, Stored Procedure..

Ensure that if you want to return data (anything other than a single scalar value) that the output can actually be mapped to a datatable. SProcs that use OUT parameters will generate a function with ByRef arguments in vb. You must pass in variables, not constants, and when the function returns, the bvariables you passed in will have the values placed in the OUT params by the sproc
 
All my other stored procs do show up in the QueriesTableAdapter in Dataset designer, but since they are not in the Data Sources tab, I can't drag them over to a form. Can I still use them?

Over half of my queries use temp tables of some kind, either #tables or ##tables. I don't think it understands them. For those, maybe I just need to do it all in code.
 
Last edited:
I get the feeling you didnt understand my post

It only makes sense to put a stored procedure into a tableadapter that is associated with some database table, if that stored procedure can do anything with that table

For example. you have a stored procedure that counts the number of customers address that are missing their Zip code. Why on earth would you want to put this sproc in the table adapter that reads financial information about the company shares? You wouldnt..

Yes, you can still use them:

VB.NET:
Dim x as New QueriesTableAdapter
 
x.MySprocName(arg1, arg2, arg3)
 
Additionally, they may be available in the ToolBox. TableAdapters never appear in the DataSources window because they do not represent a block of data, merely a device for realising it. They only appear on a form when you drag something from data sources because they are needed to bring data from database to screen - youve actually dragged a data table for example but vb knows that youre going to want to shunt data so it creates:
DataSet
Relevant TableAdapter, BindingSource, BindingNavigator (sometimes)
DataGrid/Control to show Data
 
Back
Top