Archive

Archive for the ‘C#’ Category

Visual Studio 2008 Dynamic Data Web Appliction Database Scaffolds

February 26th, 2009
Recently I’ve been addicted to using Subsonic which is AWESOME, especially when you are converting a legacy Application a web based
RIA Application! It save me hours of tedious coding. Point being they have a very nice scaffolding feature which creates web pages that
become a nice little management console for your database. The only catch is you need to have created all of your table references.
 
Well I couldn’t figure out for the life of me how to grab it and publish it to a web site so I could use it from anywhere. Instead I always had to have SubStage running. I hated this, so we found another way, which is just as nice. Here is step by step how its done.
 
Enjoy!
 

 
Create A new Visual Studio 2008 SP1 Project using Dynamic Data Web Application
 
 
Using Server Explorer (View > Server Explorer) Add a new Database Connection
 
 
 
Add A New Item to WebAppliction1 (in Solution Explorer Right Click WebAppliction1)
 
 
 
Back to Server Explorer
 
Select All the tables and drag them into the myDBLINQ.dbml
 
 
back to Solution Explorer
Open the myDBLINQ.designer.cs and copy the className highlighted (myDBLINQDataContext)
 
Open Global.asax
Uncomment the line that looks like
Replace YourDataContextType with the line you previously copied myDBLINQDataContext
   and set ScaffoldAllTable = true
 
 
Now Run the Debugger.  Clicking OK through the Prompt Below.
 
 
 
You should now have Scaffolding for your database…without writing a line of code
 

Greg C#

Subsonic MSSQL Stored Proc with no parameters

February 9th, 2009

Typically you would call a stored proc using Subsonic using the following.


public DataSet OverallStatus()
{
return SPs.PGetColorCoding().GetDataSet();

}

However, Subsonic has a problem getting the Object class for your stored proc when there are no parameters to pass in.  So we just we just convert it to a string doing the following


public DataSet OverallStatus()
{
StoredProcedure sp = SPs.PGetColorCoding();
string dummy = sp.Command.CommandSql;
return sp.GetDataSet();
}

Greg C#, Subsonic ,