Lucian Bumb Lucian Bumb - 1 year ago 72 Question

How to call a stored procedure imported from a database using add new datasource

In my project I went on Data source window and click add new, and I imported a stored procedure with 3 parameters (pivot table stored procedure).

In Solution Explorer appear a data set, with double click on this data set I open it and see my procedure there like a QueryTableAdapter.

I want to run this procedure but I do not know how.

The procedure is functional, the database is made in SQL Server, I want to run it in Visual Basic.

My questions are:

  1. Why a simple procedure with parameters is imported like table and you can drag & drop on a form from datasource and a stored procedure for pivot table is not imported like table?

  2. How can I run an pivot table stored procedure imported in the project by using "Add New Datasource" from database.

Answer Source

Stored procedures that do not return rows are imported into a query adapter. It's like a tableadapter specifically for functions that return a single value.

dim Adapter as new YourdatabasenamequryAdapter
'YourFunction is a method inside the query adapter
Dim x as boolean = YourdatabasenamequryAdapter.yourFunction(YourParams)

Any procedure that that returns multiple rows will import as a table.

    Dim table as new yourprocedureTable ' heres a table to fill
Dim adapter as new yourprocedureadapter ' here is a class for invoking you           'procedure
'to run the proceedure
adapter.fill(table,param1,param2...) 'You give it a table to fill and call         the 'fill method.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download