Search for Stored Procedures in source code

During the development process of an ASP.NET web application, the number of
stored procedures used can grow alarmingly. More often than not, I forget to
document
which stored procedures are being used and which are redundant. So, I decided
to build a little utility that searched through my source code to find all
instances of stored procedures being used.
My goal was to have a web page that listed the procedures being used on each
page. In IE6, I could then right-click on the table and export the list to
Excel. Useful for future documentation.

First of all we start by looping through directories in our root folder:

		private string FileTypes="*.cs";
		private void DirSearch(string Dir) 
		{
			try	
			{
				foreach (string f in Directory.GetFiles(Dir, FileTypes)) 
				{
					ReadFile(f);
				}
				foreach (string d in Directory.GetDirectories(Dir)) 
				{
					DirSearch(d);
				}
			}
			catch (Exception e)
			{
				Response.Write(e.Message);
			}
		}

Like many other, all my stored procedures begin with “sp”, so we can read
each file and look for all instances of “sp*” and store them in a datatable.

		private string SearchExpression="\"(sp[^\"]+)\"";
		private void ReadFile(string fn)
		{
			StreamReader s = new StreamReader(fn);
			string read = s.ReadToEnd();
			s.Close();
			Regex r = new Regex(SearchExpression);
			MatchCollection mc=r.Matches(read);
			foreach (Match m in mc) 
			{    
				DataRow dr=dt.NewRow();
				dr["SP"]=m.Groups[1];
				dr["Page"]=fn.Substring(Folder.Length+1);
				dt.Rows.Add(dr);
			}
		}

Next, we can bind the Datatable to a Datagrid:

		private string Folder=@"c:\mywebsite";
		private void BindData()
		{
			dt=new DataTable();
			dt.Columns.Add("SP");
			dt.Columns.Add("Page");
			DirSearch(Folder);
			DataView dv=dt.DefaultView;
			dv.Sort=SortColumn;
			DataGrid1.DataSource=dv;
			DataGrid1.DataBind();
		}

And then bring it all together when the pages loads:

		private void Page_Load(Object src,EventArgs e) 
		{
			if (!IsPostBack)
			{
				SortColumn="SP";
				BindData();
			}
		}
Updated: March 5, 2015 — 11:06 pm

Comments

Add a Comment
  1. Your comment is awaiting moderation.

    Factor nicely regarded!.
    http://cialismsnrx.com/
    cialis uk nhs
    cialis 20 mg
    cialis diario pague menos
    cialis 20mg

  2. Your comment is awaiting moderation.

    This is nicely said! .
    http://cialisttk.com/
    cialis tadalafil 20mg original
    generic cialis
    cialis opinions
    cialis online

  3. Your comment is awaiting moderation.

    Nicely put, Cheers.
    http://cialismsnntx.com/
    composição quimica do cialis
    cialis without a doctor prescription
    o que Г© cialis yahoo
    buy cialis online

  4. Your comment is awaiting moderation.

    You actually mentioned it adequately!
    http://cialispego.com/
    prix cialis paris pharmacie
    cialis without a doctor prescription
    cialis kaufen gГјnstig deutschland
    cialis online

  5. Your comment is awaiting moderation.

    You reported it fantastically!
    http://cialispego.com/
    cuanto cuesta cialis generico mexico
    buy cialis online
    cialis da 10 o da 20
    cheap cialis

  6. Your comment is awaiting moderation.

    You reported it well!
    http://cialisttk.com/
    how to buy cheap cialis
    cialis 20mg
    cialis daily vs as needed
    cialis 20 mg

  7. Your comment is awaiting moderation.

    You definitely made the point.
    http://cialisttk.com/
    priligy combinado con cialis
    cialis 20mg
    alfuzosin and cialis
    cialis 20 mg

  8. Your comment is awaiting moderation.

    Cheers. A lot of material.

    https://www.cialismim.com/
    oryginalny cialis gdzie kupic
    cialis generic
    cialis powder conversion
    cialis without a doctor prescription

  9. Your comment is awaiting moderation.

    You revealed it superbly!
    http://cialisttk.com/
    donde comprar cialis foro
    cialis without a doctor prescription
    pourquoi le cialis ne fonctionne pas
    cialis generic

  10. Your comment is awaiting moderation.

    You actually expressed that effectively!
    http://cialispego.com/
    cialis eye problems
    cialis 20 mg
    cialis generic price
    cheap cialis

  11. Your comment is awaiting moderation.

    With thanks, I value it!
    http://cialisttk.com/
    vega mД± cialis mi
    cialis 20mg
    diferencia entre cialis original y generico
    cialis generic

  12. Your comment is awaiting moderation.

    You actually stated that adequately!
    http://cialisttk.com/
    cubre cialis la seguridad social
    generic cialis
    when can you take cialis
    buy cialis online

  13. Your comment is awaiting moderation.

    Many thanks. I like it.
    https://www.cialismim.com/
    cialis egiziano
    cialis 20mg
    cialis reduce sperm count
    cialis without a doctor prescription

  14. Your comment is awaiting moderation.

    You have made your point pretty clearly..
    http://cialismsnrx.com/
    cialis farmacia doctor simi
    cialis without a doctor prescription
    cialis generico da 10 mg
    cialis 20 mg

  15. Your comment is awaiting moderation.

    You actually explained it well!
    http://cialismsnrx.com/
    cialis professional ingredients
    cialis online
    come posso comprare cialis
    buy cialis online

  16. Your comment is awaiting moderation.

    You actually mentioned it well!
    https://www.cialismim.com/
    wie cialis teilen
    cialis 20mg
    cialis national health
    cheap cialis

  17. Your comment is awaiting moderation.

    Position effectively applied!!
    http://cialisttk.com/
    cialis online per nachnahme
    generic cialis
    cialis dolor de riГ±ones
    cheap cialis

  18. Your comment is awaiting moderation.

    You reported it very well!
    http://cialismsnntx.com/
    generic cialis 10mg online
    cheap cialis
    cialis neocalis
    cialis 20 mg

  19. Your comment is awaiting moderation.

    Amazing quite a lot of awesome info!
    https://www.cialismim.com/
    cialis et sep
    cheap cialis
    cialis controindicazioni pressione
    cheap cialis

  20. Your comment is awaiting moderation.

    Kudos. An abundance of information.

    https://www.cialisfidel.com/
    desconto cialis diario
    cialis 20mg
    natural alternative to viagra or cialis
    buy cialis online

  21. Your comment is awaiting moderation.

    You said this well.
    http://cialismsnrx.com/
    diЕџi yakarД±Еџ cialis
    cialis 20mg
    health insurance coverage for cialis
    cialis without a doctor prescription

  22. Your comment is awaiting moderation.

    Kudos. Fantastic information!
    https://www.cialisfidel.com/
    quanto tempo prima bisogna assumere cialis
    buy cialis online
    que tal es la cialis
    cheap cialis

  23. Your comment is awaiting moderation.

    Amazing quite a lot of excellent information!
    http://cialispego.com/
    el cialis y la diabetes
    cialis 20 mg
    cialis superdrug
    cheap cialis

  24. Your comment is awaiting moderation.

    Superb postings, Thank you!
    https://www.cialismim.com/
    cialis yetkili satД±Еџ
    cialis without a doctor prescription
    precio de cialis en farmacia roma
    cialis 20mg

  25. Your comment is awaiting moderation.

    You mentioned this wonderfully.
    http://cialismsnrx.com/
    cialis tГ©moignages
    cialis without a doctor prescription
    psychological ed cialis
    cialis online

  26. Your comment is awaiting moderation.

    Excellent material. Thank you.
    http://cialismsnntx.com/
    cialis serve la ricetta medica
    generic cialis
    eczane cialis ankara
    cheap cialis

  27. Your comment is awaiting moderation.

    Reliable advice. Regards.
    https://www.cialisfidel.com/
    taking cialis before drinking
    generic cialis
    differences between cialis and levitra
    cialis 20mg

  28. Your comment is awaiting moderation.

    You have made your position very clearly!!
    https://www.cialismim.com/
    cialis+verschreibungspflichtig+holland
    cialis online
    what would happen if i took a cialis
    buy cialis online

  29. Your comment is awaiting moderation.

    Many thanks! Good stuff.
    http://cialismsnntx.com/
    cialis farmacie online
    cialis 20 mg
    generic cialis pattaya
    cialis 20 mg

  30. Your comment is awaiting moderation.

    You’ve made your point!
    http://cialisttk.com/
    cialis walmart pharmacy
    cialis generic
    cialis 20 mg n1
    cialis 20mg

  31. Your comment is awaiting moderation.

    Incredible many of terrific data.
    http://cialisttk.com/
    cialis brevet canada
    cialis 20 mg
    acheter cialis au portugal
    cialis generic

  32. Your comment is awaiting moderation.

    Truly plenty of helpful facts.
    http://cialisttk.com/
    can you mix alcohol and cialis
    cialis online
    can you import cialis into australia
    generic cialis

  33. Your comment is awaiting moderation.

    You made your position quite effectively!.
    https://www.cialisfidel.com/
    generic cialis online europe
    cialis 20 mg
    cheaper than cialis
    cialis generic

  34. Your comment is awaiting moderation.

    Really all kinds of helpful advice!
    https://www.cialismim.com/
    notice utilisation cialis
    cialis online
    cialis online gГјnstig kaufen
    cheap cialis

  35. Your comment is awaiting moderation.

    With thanks. Excellent stuff!
    http://cialisttk.com/
    priligy und cialis zusammen einnehmen
    cialis 20 mg
    cialis uk supply
    generic cialis

  36. Your comment is awaiting moderation.

    Fine facts. Thanks a lot!
    http://cialismsnrx.com/
    generic cialis 10mg reviews
    buy cialis online
    informasi tentang cialis
    buy cialis online

  37. Your comment is awaiting moderation.

    Thanks a lot! Loads of knowledge.

    http://cialismsnrx.com/
    durata del cialis 5 mg
    cheap cialis
    packungsgrößen cialis 5mg
    cheap cialis

  38. Your comment is awaiting moderation.

    Kudos, I enjoy this.
    https://www.cialisfidel.com/
    can i split a 20mg cialis pill in half
    cialis online
    cialis vs blood pressure
    generic cialis

  39. Your comment is awaiting moderation.

    Thanks a lot! A lot of forum posts.

    http://cialispego.com/
    cialis beste wirkung
    cialis without a doctor prescription
    how soon before should i take cialis
    buy cialis online

  40. Your comment is awaiting moderation.

    Truly all kinds of great material!
    http://cialisttk.com/
    is viagra more effective than cialis
    cialis without a doctor prescription
    cialis patent life
    cialis 20mg

  41. Your comment is awaiting moderation.

    Reliable data. Regards.
    https://www.cialisfidel.com/
    acheter cialis sur internet avis
    cialis generic
    what happens with cialis and alcohol
    cheap cialis

  42. Your comment is awaiting moderation.

    Beneficial postings. Kudos!
    http://cialisttk.com/
    how much cialis can you take
    cialis online
    taking cialis with food
    cialis generic

  43. Your comment is awaiting moderation.

    With thanks! Quite a lot of content!

    http://cialismsnrx.com/
    viagra cialis wikipedia
    cialis 20mg
    the cialis bathtubs
    cialis online

  44. Your comment is awaiting moderation.

    Nicely put, Kudos!
    http://cialismsnntx.com/
    cialis for a young man
    generic cialis
    qual o nome do remedio generico do cialis
    buy cialis online

  45. Your comment is awaiting moderation.

    Point well considered..
    https://www.cialismim.com/
    valor do remГ©dio cialis
    cialis generic
    principio attivo viagra cialis levitra
    cialis online

  46. Your comment is awaiting moderation.

    With thanks! Quite a lot of tips!

    https://www.cialisfidel.com/
    cialis mail order australia
    cheap cialis
    cialis legal dubai
    cialis online

  47. Your comment is awaiting moderation.

    This is nicely said! .
    https://www.cialismim.com/
    generic cialis nz
    cialis online
    quanto tempo prima assumere il cialis
    cialis online

  48. Your comment is awaiting moderation.

    You reported this terrifically!
    https://www.cialismim.com/
    comparativa viagra cialis levitra
    cheap cialis
    pharmacie toulouse cialis
    cialis without a doctor prescription

  49. Your comment is awaiting moderation.

    Superb posts. Regards.
    http://cialismsnntx.com/
    cadastro para compra de cialis com desconto
    generic cialis
    5 hour energy cialis
    cialis generic

  50. Your comment is awaiting moderation.

    Many thanks, Wonderful stuff.
    https://www.cialisfidel.com/
    cialis 20 mg 2 li
    cialis generic
    cialis c20 erfahrungen
    cialis 20mg

  51. Your comment is awaiting moderation.

    Truly loads of terrific data!
    https://www.cialisfidel.com/
    el cialis se vende con receta medica en chile
    cialis 20mg
    cialis at superdrug
    cialis generic

  52. Your comment is awaiting moderation.

    Thanks! Numerous write ups.

    http://cialismsnntx.com/
    cialis ocular side effects
    cialis 20 mg
    cialis norvasc interaction
    cheap cialis

  53. Your comment is awaiting moderation.

    Truly a good deal of valuable material.
    http://cialispego.com/
    when is cialis patent up
    generic cialis
    do you need a prescription for cialis in ontario
    cialis without a doctor prescription

  54. Your comment is awaiting moderation.

    With thanks, Plenty of data.

    http://cialismsnntx.com/
    efecto cialis tiempo
    generic cialis
    treat cialis headache
    cialis generic

  55. Your comment is awaiting moderation.

    Fantastic forum posts. Thank you!
    http://cialismsnrx.com/
    health insurance and cialis
    cialis 20mg
    var köper jag cialis
    buy cialis online

  56. Your comment is awaiting moderation.

    You explained that terrifically.
    http://cialismsnrx.com/
    obtaining cialis
    cialis generic
    cialis wirkung bei frau
    cialis online

  57. Your comment is awaiting moderation.

    Whoa quite a lot of valuable data.
    https://www.cialismim.com/
    is cialis super active better
    cheap cialis
    how long does cialis 10mg last
    cheap cialis

  58. Your comment is awaiting moderation.

    With thanks. Valuable information.
    http://cialismsnntx.com/
    cialis with other medications
    generic cialis
    cialis 20 opiniones
    cheap cialis

  59. Your comment is awaiting moderation.

    Thanks a lot. Helpful stuff.
    http://cialispego.com/
    directions for cialis 20 mg
    cialis without a doctor prescription
    cialis brno
    buy cialis online

  60. Your comment is awaiting moderation.

    Seriously lots of useful material!
    http://cialismsnrx.com/
    cialis viagra preço
    cheap cialis
    cialis pharmacy spain
    cialis 20 mg

  61. Your comment is awaiting moderation.

    Helpful data. Kudos!
    https://www.cialisfidel.com/
    when should one take cialis
    generic cialis
    does cialis work performance anxiety
    cialis 20 mg

  62. Your comment is awaiting moderation.

    Nicely spoken truly! .
    https://www.cialisfidel.com/
    safe daily dose of cialis
    cialis generic
    cialis nevriye budak
    cialis 20 mg

  63. Your comment is awaiting moderation.

    Thanks, Excellent information!
    http://cialismsnrx.com/
    cialis o parecido
    cialis 20mg
    cialis 20 pareri
    buy cialis online

  64. Your comment is awaiting moderation.

    Thank you! Awesome information!
    https://www.cialisfidel.com/
    cialis 20 prezzo
    buy cialis online
    cost of cialis tablets
    cialis 20mg

  65. Your comment is awaiting moderation.

    Kudos, Very good stuff.
    http://cialispego.com/
    how long does it take cialis to get in your system
    cialis without a doctor prescription
    cialis opis dziaЕ‚ania
    cialis 20mg

  66. Your comment is awaiting moderation.

    Many thanks! I like it!
    http://cialismsnrx.com/
    who is the actress in the cialis commercial
    generic cialis
    cialis hoe gebruiken
    cialis generic

  67. Your comment is awaiting moderation.

    Really all kinds of very good material!
    http://cialismsnntx.com/
    prices for cialis walmart
    generic cialis
    what is the cost of cialis without insurance
    cialis 20 mg

  68. Your comment is awaiting moderation.

    This is nicely expressed. .
    http://cialisttk.com/
    cialis contrareembolso
    cheap cialis
    cialis kenya
    buy cialis online

  69. Your comment is awaiting moderation.

    This is nicely said! !
    http://cialispego.com/
    cialis cardura
    cialis generic
    ag guys liquid cialis reviews
    cialis 20 mg

  70. Your comment is awaiting moderation.

    Seriously a lot of amazing information!
    http://cialisttk.com/
    cialis soft tabs canada
    buy cialis online
    cialis for urinary incontinence
    cheap cialis

  71. Your comment is awaiting moderation.

    Truly tons of very good info.
    http://cialismsnrx.com/
    how cialis viagra works
    cialis generic
    cialis before going out
    cialis without a doctor prescription

  72. Your comment is awaiting moderation.

    You said it nicely..
    http://cialismsnrx.com/
    cialis just stop working
    buy cialis online
    cialis stops working
    cialis generic

  73. Your comment is awaiting moderation.

    Great content. Thanks!
    http://cialismsnrx.com/
    cialis and hair loss
    cialis online
    preiswert cialis kaufen
    cialis online

Leave a Reply

Your email address will not be published. Required fields are marked *