473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Reflection to Dynamically Determine Stored Procedure Name

Hi,

My boss has asked me to create a tool that can give us a list of
stored procedure names that are being called from each of our app's
web pages. This is an ASP.NET application that is rather large and
about 5 years old. I am not here to debate the logic of the request.

The structure of most the application is pretty standardized: We
created a business/data layer that contains methods that have the
names of the stored procedures to call as hard coded strings. The
stored procedures all begin with "USP_", so should be pretty easy to
ferret out.

My initial thought was to use reflection to start at the ASP.NET
assembly, then work my way down to the business/data layer assembly.
So the end report would tell you each namespace.class.method that
leads up to the proc and look something like:

-CompanyApp.Defaultl.aspx.cs.PageLoad()
--BizLayer.GetCustomerData()
---DataLayer.GetCustome()
----"USP_Customer_Get"
Has anyone tried to do anything like this before? Does anyone have any
suggestions on where to begin or can you point me to a tutorial on
something similar?

Thanks for any help you can provide.

Tod Birdsall
http://tod1d.net
Jun 27 '08 #1
3 1933
If you have access to the source code, there's no reason that you couldn't
just do a file system search. If that's true, I don't see the need to get
more elaborate. I've done the same thing for a body of source code that
amounts to several hundred thousands of lines of code, and it was no big
deal.

Tom Dacon
Dacon Software Consulting

"Tod Birdsall" <tb*******@gmail.comwrote in message
news:96**********************************@26g2000h sk.googlegroups.com...
Hi,

My boss has asked me to create a tool that can give us a list of
stored procedure names that are being called from each of our app's
web pages. This is an ASP.NET application that is rather large and
about 5 years old. I am not here to debate the logic of the request.

The structure of most the application is pretty standardized: We
created a business/data layer that contains methods that have the
names of the stored procedures to call as hard coded strings. The
stored procedures all begin with "USP_", so should be pretty easy to
ferret out.

My initial thought was to use reflection to start at the ASP.NET
assembly, then work my way down to the business/data layer assembly.
So the end report would tell you each namespace.class.method that
leads up to the proc and look something like:

-CompanyApp.Defaultl.aspx.cs.PageLoad()
--BizLayer.GetCustomerData()
---DataLayer.GetCustome()
----"USP_Customer_Get"
Has anyone tried to do anything like this before? Does anyone have any
suggestions on where to begin or can you point me to a tutorial on
something similar?

Thanks for any help you can provide.

Tod Birdsall
http://tod1d.net

Jun 27 '08 #2
Thank you both for your reply. It is good to know that Reflection
won't help me. Reflector is very useful, but I don't think it will
work for the problem I am trying to solve.

The problem is that my boss, who is a DBA and not a programmer, wants
to know what stored procedures are being called by each aspx page. If
no developer is available to troubleshoot an issue with an aspx page,
he would like to know what procs the page is calling so he might be
able to troubleshoot the problem from the database side. I have access
to the source code and can easily search through it to get a list of
procs that are used by each of the three assemblies that are being
used in this application. The data layer is in a separate assembly
from the website and, to make things more interesting, the website
itself is not in single assembly.

I think I will need to look at this problem from another angle, or
possibly go the ildasm route, if possible.

Tod Birdsall
http://tod1d.net

On Jun 6, 8:50 pm, "Tom Dacon" <tda...@community.nospamwrote:
If you have access to the source code, there's no reason that you couldn't
just do a file system search. If that's true, I don't see the need to get
more elaborate. I've done the same thing for a body of source code that
amounts to several hundred thousands of lines of code, and it was no big
deal.

Tom Dacon
Dacon Software Consulting

"Tod Birdsall" <tbirds...@gmail.comwrote in message

news:96**********************************@26g2000h sk.googlegroups.com...
Hi,
My boss has asked me to create a tool that can give us a list of
stored procedure names that are being called from each of our app's
web pages. This is an ASP.NET application that is rather large and
about 5 years old. I am not here to debate the logic of the request.
The structure of most the application is pretty standardized: We
created a business/data layer that contains methods that have the
names of the stored procedures to call as hard coded strings. The
stored procedures all begin with "USP_", so should be pretty easy to
ferret out.
My initial thought was to use reflection to start at the ASP.NET
assembly, then work my way down to the business/data layer assembly.
So the end report would tell you each namespace.class.method that
leads up to the proc and look something like:
-CompanyApp.Defaultl.aspx.cs.PageLoad()
--BizLayer.GetCustomerData()
---DataLayer.GetCustome()
----"USP_Customer_Get"
Has anyone tried to do anything like this before? Does anyone have any
suggestions on where to begin or can you point me to a tutorial on
something similar?
Thanks for any help you can provide.
Tod Birdsall
http://tod1d.net
Jun 27 '08 #3
Tod Birdsall wrote:
The problem is that my boss, who is a DBA and not a programmer, wants
to know what stored procedures are being called by each aspx page. If
no developer is available to troubleshoot an issue with an aspx page,
he would like to know what procs the page is calling so he might be
able to troubleshoot the problem from the database side.
If he wants it for troubleshooting, he can just run SQL Server Profiler to
see what's *actually* being executed at the DB side at the time trouble
happens. That's probably more helpful than a theoretical list of what pages
*might* be calling what (which could be highly variable depending on input),
especially if he can't actually change the source.

It's a bit silly, really. If I had a DBA like that I'd say "I'll call
whatever stored procedure is in the DB, whenever I want, in whatever way I
want, permissions willing". Since the DBA can't understand or fix my code,
he has no business knowing it in further detail, and indeed the whole point
of setting up the DB this way is that he doesn't need to. If he wants to fix
problems at the DB side, he can; he's got all the tools he needs for that.
But there's no benefit to him knowing what ASPX page does what, if only for
the reason that such a list is bound to become outdated and worse than useless.

Print this and show it to your boss for interesting conversation! :-)
I have access to the source code
Problem solved? FINDSTR on the lot and the file name should match the page.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark Oueis | last post by:
Is there any way I can retrieve the result set of a Stored Procedure in a function. ALTER FUNCTION dbo.fn_GroupDeviceLink ( @groupID numeric ) RETURNS @groupDeviceLink TABLE (GroupID numeric,...
5
by: Frazer | last post by:
hi could any one tell me which real life senarios reflection can be used in ? thnx
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Mike Hutton | last post by:
I have a rather odd problem. I have a SP which uses temp. tables along the way, and then returns a table of results: CREATE PROCEDURE dbo.usp_myproc( @pNameList VARCHAR(6000) ) AS
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
1
by: Chad | last post by:
2131 Public Property ContactId() As SqlInt32 2132 Get 2133 Return MyBase.SqlInt32Property("ContactId") 2134 End Get 2135 ...
4
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup,...
37
by: sam44 | last post by:
Hi, At startup the user log on and chooses the name of a client from a dropdownlist, which then changes dynamically the connection string (the name of the client indicates which database to use)....
4
by: Søren M. Olesen | last post by:
Hi Is it (any way) possible using reflection to set an indicator (property, variable, attribute,..). on an object before it actually instantiated, so that this indicator can be used in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.