.NET Answers

ASP.NET, HTML, CSS, Visual Studio, CSharp, VB.NET and other programming items of interest.
Subscribe
  • Home
  • About Me
  • Advertising
  • Click Here to Ask a question
    • Privacy Policy
  • Site Map

DotNetNuke – Modules – Creating Stored Procs

July 29, 2008 By: Dave

image Now that we have our tables created, we are going to use the CodeSmith product that we installed last week to create our stored procedures.

We will also end up creating the SQL scripts that we will need to install this module into another DNN installation.

So, the first thing you need to do is to fire up CodeSmith. Under the DotNetNuke folder that we attached when we installed CodeSmith, there should be a template named “StoredProcedures.cst”. Double click that. This will bring up the wizard window that will allow us to create the stored procedures.

At the top of the windows, you will see “MultiSourceTable.” Put your cursor in that field and click the ellipse (…) button to bring up another dialog that will allow you to specify which tables you want to attach to.

One of the first things you’ll need to do is to attach to your DotNetNuke database. Click the ellipse button on the database dialog to add a new connection to CodeSmith. Click the Add button and fill in the form on the resulting screen. The easiest way to get the connection string is to go into the web.config file of your DotNetNuke installation and grab it from there. If your database is in the app_data directory of your DotNetNuke installation, remember to replace |DataDirectory| with the full directory path where your DotNetNuke database is located.

Once you have your connection established, you can select it from the list and select the database you want to create the stored procedures for.

I generally leave all the default options. You will need to fill in the ObjectQualifier with the prefix you used for your table names. Remember last week I told you to prefix your table names with something about your company? There are three reasons for this. First, it reduces the chance that some other company will use the same table name you decided to use. Kind of like name spacing your classes. Second, the wizard wants the object qualifier. If it doesn’t find the string you put in for the object qualifier at the beginning of your table names, it will prefix the code it generates with that code and you’ll have to fix it up. This is more of a problem with the other wizards we will be using, but it is still a problem. Third, when you go into the database to look for one of the tables you are working with, it will be a lot easier to find the group than to go looking for one out of a hundred.

At the bottom of the window is the “Generate” button. Click this to generate the stored procedure script which will show up already selected and ready to copy to the clipboard on the right. The first thing you’ll want to do with this script is to copy it into the 01.00.00.SqlDataProvider file that the DotNetNuke module creation wizard placed in your DeskTopModules/moduleName directory. The other thing you’ll want to do is to run this script in DotNetNuke.

Notice, you can not run this script anywhere other than in DotNetNuke because it has two markers in it that will get replaced by DotNetNuke when it is run.

The first marker is {databaseOwner}. In most systems this will get replaced by “dbo.” But, DotNetNuke allows you to specify another dbo user in the web.config file and if it is specified, that string will be used instead of “dbo”.

The second marker that will get replaced is {objectQualifier}. This allows multiple DotNetNuke installations to share the same database, or to share a database with another application with tables of the same name. Again, this is something that can be specified in the web.config file. If the string exists, {objectQualifier} will be replaced with that string.

Keep this in mind as you create other stored procedures that you may need. Anywhere you would normally use “dbo.”, you should use {databaseOwner} and anyplace you would specify a table name, index or key you’ll want to include {objectQualifier}. For example, tableName would become {objectQualifier}tableName and FK_Keyname would become FK_{objectQualifier}KeyName.

If you are using tools like Microsoft SQL Studio Express to create your scripts, this can be done with a simple search and replace operation.

To run this script we created, run your DotNetNuke development installation, log in as a “host” user and navigate to the “Host” > “SQL” window. Paste the SQL script into that window, check the “run as script” check box and click the “Execute” link.

You now have about 80% of your stored procedures in your database.

 

Other post in DotNetNuke - Module Development
  • Creating DotNetNuke Modules - May 20th, 2008
  • Creating DNN Modules - The Tools - May 22nd, 2008
  • DotNetNuke Modules - Foundational Concepts - May 26th, 2008
  • DotNetNuke Modules - Install DNN into VS 2008 - May 27th, 2008
  • DotNetNuke Modules - Creating Base Modules - May 28th, 2008
  • DotNetNuke Modules - Registering Your Module - May 29th, 2008
  • DotNetNuke Modules - Where Stuff Shows Up - June 3rd, 2008
  • DotNetNuke Modules - Benefits of Architecture - June 4th, 2008
  • DotNetNuke Modules - Anatomy of the View - June 9th, 2008
  • DotNetNuke Modules - Adding Actions - June 11th, 2008
  • DotNetNuke Modules - DNN Controls - Label - June 18th, 2008
  • DotNetNuke - Internationalization - June 25th, 2008
  • DotNetNuke Modules - Internationalization (part 2) - June 30th, 2008
  • DotNetNuke Modules - Labels w/ no Help - July 9th, 2008
  • DotNetNuke Modules - LinkButtons - July 14th, 2008
  • DotNetNuke Modules - Collapsible Panels - July 16th, 2008
  • DotNetNuke - The Data Layer - Installing CodeSmith - July 22nd, 2008
  • DotNetNuke - Modules - Creating The Tables - July 24th, 2008
  • DotNetNuke - Modules - Creating Stored Procs - July 29th, 2008
  • DotNetNuke - Modules - Portal Specific Modules - July 31st, 2008
  • DotNetNuke Modules - Data Access Layer - August 5th, 2008
  • DotNetNuke Modules - Data Access Layer - August 7th, 2008
  • DotNetNuke - Data Access Layer Alternative - August 12th, 2008
  • DotNetNuke - Modules - Linking within the module - August 14th, 2008
  • DotNetNuke - Make Your Module Searchable - August 19th, 2008
  • DotNetNuke Modules - Making Content Portable - August 25th, 2008
  • DotNetNuke Modules - Exceptions the DNN Way - September 2nd, 2008
  • DotNetNuke Modules - PortalModuleBase - September 4th, 2008
  • DotNetNuke Modules - Inter Module Communication - September 9th, 2008
  • DotNetNuke Modules - Finding The Page a Module is On - September 15th, 2008
  • DotNetNuke Modules - Caching - September 17th, 2008
  • DotNetNuke Modules - Module Settings - September 22nd, 2008
  • DotNetNuke Modules - Retrieving Settings - September 24th, 2008
  • DotNetNuke Modules - Advanced Architecture - October 20th, 2008
  • DotNetNuke Modules - Creating the PA - October 30th, 2008
  • DotNetNuke Modules - Automating the PA - November 5th, 2008
  • DotNetNuke - FileUploadControl Danger! - February 26th, 2009

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Most Commented Post

  • Object Oriented Programming has Failed Us
  • Microsoft’s Biggest Mistake with ASP.NET
  • WordPress w/ Forms Authentication on IIS6
Bookmark to:

Add to Del.icio.us Add to digg Add to DotNetKicks Add to DZone Add to Facebook Add to Slashdot Add to Stumble Upon Add to Technorati
Hide Sites

One Response to “ DotNetNuke – Modules – Creating Stored Procs ”

  1. # 1 kolors Says:
    March 25th, 2009 at 6:49 am

    GOOD JOB!!!

    Without this i would need much more to create my module and even then it would be crap!!!

← 5 Tips to Make You a Valuable Programmer.
Using JSON in ASP.NET →
  • Search

  • Subscribe

    U COMMENT
    I FOLLOW

    Subscribe in a reader

    OR

    Subscribe via e-mail

    Enter your email address: 

    Delivered by FeedBurner

     

  • Follow Me

    • Twitter
    • FaceBook
    • Digg
    • StumbleUpon
    • Propeller
    • Delicious
    • Plaxo

     

  • Recent Posts

    • ASUS Eee PC 1005HA-PU1X-BK Black Netbook
    • jQuery – Date Picker
    • Using VB.NET From CSharp
    • iTextSharp – Adding Images
    • Hungarian Notation – Use What Works, Spit Out The Bones
    • Pre Order Windows 7
    • jQuery Dialog – With Validation Controls
    • iTextSharp – The easy way
    • Structure of my ASP.NET Web Applications
    • 35% Off Accronis True Image 2009 Home
    • VB.NET Hide Module Name
    • ASP.NET/VB.NET – Video Training
    • Does jQuery Make Us Lazy?
    • PDFs Using iTextSharp
    • Programming SEO – Ping



  • Advertise on this site through Lake Quincy Media
  • DotNetNuke Sponsor

     

    Most Valuable Blogger
  • Sponsor

  • Categories

    • Advanced CSharp
    • Advanced VB.NET
    • ASP.NET MVC
    • Did you know
    • DotNetNuke – Module Development
    • DotNetNuke – Skinning
    • internationalization
    • iTextSharp
    • jQuery
    • none
    • Seach Engine Optimization
    • Silverlight
    • SQL For Programmers
    • Twitter
    • winforms
  • Cloud

    .net ajax architecture asp.net book books containers csharp css dal dataset datasets dotnetnuke events gridview images internationalization internet explorer javascript jQuery json linq listview modules ms-sql MVC objectdatasource programming reflection seo Silverlight skinning sql testing tsql tutorial Twitter twitterizer vb.net video view Vista visual studio webservice WordPress
  • Archives

    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
    • Privacy Policy
  • Calendar

    July 2008
    S M T W T F S
    « Jun   Aug »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Blogroll

    • Alvin Ashcraft’s Morning Dew
    • ASP.NET Consulting
    • Life Hacker
    • Remember Anything
    • The Price of Their Toys
    • Uncategorized Thought


.NET Answers © 2007 - 2008 All Rights Reserved.
Entries and Comments.