Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Database accessed through web service or stored procedure

I have a grid that is populated and displays the data to a grid.

WEBSERVICE:
Is there a benefit to passing the ad hoc query that populates that grid to a web service and returning an object? This has been a recommendation. But when stepping through the code, the spinner spins when the grid is actually populated with the datasource:
grdSelector.DataSource = blah

So I don't really see a benefit of using the webservice to speed up the grid load. But I just don't know.

STORED PROCEDURE:
I do use stored procedures for all CRUD operations other than populating grids based on search criteria. When the query is built from search criteria, I use the ad hoc query to a SQLCommand to a DataTable.

What is your opinion on taking my query and putting it in a stored procedure instead of an ad hoc query using a SQL Command to a DataTable?

(The query is extremely huge and detailed based on numerous tables and where clauses, inner joins, etc. The query changes depending on the search criteria selected by the user running the report.)

Thanks!
0
Starr Duskk
Asked:
Starr Duskk
  • 3
  • 3
1 Solution
 
lcohanDatabase AnalystCommented:
"The query is extremely huge and detailed based on numerous tables and where clauses, inner joins, etc. The query changes depending on the search criteria selected by the user running the report."

Best candidate in my opinion for a SQL Stored proc in my opinion and please use use the EXEC sp_executesql inside it not just the EXEC commands for the dynamic code built inside it.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
If I were to build the sql query string in my code, and then pass the entire value to a stored procedure as a string and execute it there, would that be of any benefit?

Something like this:

ALTER Procedure [dbo].[prBuildSQL]
		@chvSQL text
As
	EXEC (@chvSQL)

Open in new window


(But I'd want to return a DataTable.)

Because there are so many filters and criteria for this final query and it looks up values depending who the logged in user is as it builds the query. It is a monster that changes dependent upon so many filters and report type and logged in user and their role and everything.

thanks.
0
 
lcohanDatabase AnalystCommented:
"If I were to build the sql query string in my code, and then pass the entire value to a stored procedure as a string and execute it there, would that be of any benefit?"

Not really - why not vice versa? You have the SQL SP that takes input parameters from your UI code then based on those builds the dynamic code that will in the end "(But I'd want to return a DataTable.)" - that's what a SQL Stored Proc does - returns a data set (or more - see MARS).
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Okay, what about a web service?
0
 
lcohanDatabase AnalystCommented:
In my view it is the same thing and is just different way/method to call the SQL Stored Procedure passing the parameter values and getting back the desired record set.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now