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
Solved

Database accessed through web service or stored procedure

Posted on 2014-03-18
6
297 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
  • 3
  • 3
6 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 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 39

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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 2

Author Comment

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

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syntax Issue with SSIS module 26 103
Need help Creating PowerShell Script 5 53
Generate Unique ID in VB.NET 21 60
Groupbox Control ? 2 17
In this article I will describe the Copy Database Wizard 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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

861 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