Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database accessed through web service or stored procedure

Posted on 2014-03-18
6
Medium Priority
?
303 Views
Last Modified: 2014-03-18
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
Comment
Question by:Starr Duskk
[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 40

Accepted Solution

by:
lcohan earned 2000 total points
ID: 39937776
"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
 
LVL 2

Author Comment

by:Starr Duskk
ID: 39937857
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
 
LVL 40

Expert Comment

by:lcohan
ID: 39937889
"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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 2

Author Comment

by:Starr Duskk
ID: 39938070
Okay, what about a web service?
0
 
LVL 40

Expert Comment

by:lcohan
ID: 39938083
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
 
LVL 2

Author Closing Comment

by:Starr Duskk
ID: 39938131
Thanks!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

670 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