Jim Bonnie's Blog

Sep 1

Written by: jbonnie
Saturday, September 01, 2007 11:52:49 PM 

There were a few posts about being able to run subsonic without making modification to the applications web.config file.

Rob Conery noted that this could be done, as the subcommander tool does this.

So I pinched some code from there and here is the barebones code to configure a subsconic provider in code.

DataService.Provider = new SqlDataProvider();

DataService.Providers = new DataProviderCollection();

DataProvider provider = DataService.Provider;

System.Collections.Specialized.NameValueCollection config = new System.Collections.Specialized.NameValueCollection();

config.Add("connectionStringName", ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString);

provider.Initialize("SiteSqlServer", config);

DataService.Provider.DefaultConnectionString =

ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;

DataService.Provider.GeneratedNamespace = "JB";

DataService.Providers.Add(provider);

Tags:

9 comment(s) so far...

Re: Running Subsonic without web.config changes

Jim, Im hoping you can help me out a bit here and I'm sorry if it's a dumb question but...I've been reading this post and one on the DNN forum and it finally dawned on me about what it means to not change the config file in the context of a portable DNN module (DUH) anyhow...on the DNN post, the write says that he created a class called "application" that he calls to initialize the provider. He says he left Codesmith templates to create the controller classes, but uses the "application" class code to initialize the subsonic info classes. (?) Here, you are providing code to initialize also, but I am just wondering where and how you are using this as opposed to the guy using the codesmith templates. I am just trying to wrap my head around all of this. I have an untiring desire to know WHY something works in addition to knowing how...I really appreciate your help Jim. Thanks!

By Briana on   Saturday, February 23, 2008 2:09:36 PM

Re: Running Subsonic without web.config changes

I found your download project right after this...using it I thought I was all on track until I try to use the code and get the error Can't find subsonic service in my app.config. I'm wondering if there is a way to instantiate the dataservice in a manner like DNN uses in the DataProvider.vb file. If you track it back from the Controller to the DataProvider it seems logical that the SubSonic provider could be instantiated from there...but, that's where I get lost. Anyhow, for now I can add the section to the web.config it's not that big of a deal...but, I would really like to figure this out..if for no other reason than to conquer something I now know that I don't know :-) Anyhow, there seems to be only two people that I've found talking about DNN and SubSonic and only one who is seriously talking about it...Thanks Jim (;-) Anyhow, looking for any kind of assistance you can offer...I have no problems doing the legwork...just would like to have someone to bounce the ideas off of while I navigate to the answers. Maybe a forum?? Thanks Again.

By Briana Tarrance on   Sunday, February 24, 2008 2:03:18 PM

Re: Running Subsonic without web.config changes

I am continuing to receive error on this line: 'config.Add("connectionStringName", ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString);' The error says: 'Object reference not set to an instance of an object.' But, when I step through the code, the locals window seems to show that everything has been initialized...Any idea about what could be throwing the error? According to the locals window, I have a value for config, configurationManager, connectionString, and provider....It's driving me nuts. I know I am missing some very small key to the puzzle here...

By briandus on   Sunday, February 24, 2008 2:45:47 PM

Re: Running Subsonic without web.config changes

Briana,

I am not familiar with the codesmith templates that you are referring to.
If you post some code samples, then we can figure it out together. The reason to load the SS Provider in Code is to avoid changing the web config, which can be a problem in a hosted environment.

By Jim on   Sunday, February 24, 2008 11:10:53 PM

Re: Running Subsonic without web.config changes

Hi briandus,

Did you try running the sample project that I have posted.
http://walkspoiled.com/LinkClick.aspx?fileticket=nPFI6VHL%2bC8%3d&tabid=158&mid=521

It will deploy the autoscaffold I ported for DNN and allow full access to any DNN table in the sitesqlserver connection string.

If you have control over the web config, try using the build provider as noted in rob's docs and soniccasts, http://subsonicproject.com/view/for-web-sites---using-the-buildprovider.aspx

I also have a sample project that you can use to generate the subsonic classes in its own dll, that dll can then used in any project as your complete DAL. This is also shown in Rob's docs and webcasts.

If you continue to have a problem, post your code or send me an email and we can track it down. A simple typo could be messing you up.

Jim

By Jim on   Sunday, February 24, 2008 11:18:50 PM

Re: Running Subsonic without web.config changes

Hi Jim, it's been a while...got sidetracked for a bit (um, like 7-8 months:-) Anyhow, I just installed your DNN_Scaffold module and I'm still trying to pick my jaw up. All I can say is WOW!!! I used the subsonic scaffold way back when I first found it and was amazed, but became discouraged after having so much trouble trying to play with DNN. I am absolutely shocked that I just installed one little control and made two tiny changes to the .config and Voila! OMGoodness gracious...I'm still in awe. I just couldn't let the opportunity to tell you how awesome you are for getting this done. I downloaded your other project as well and am about to play with that. All I can say is, "Good News!!". Btw, how's the golf module coming along? I'm still interested in helping out if you need or want some. Take care and thanks again!

By Briana Tarrance on   Friday, October 03, 2008 2:01:32 AM

Re: Running Subsonic without web.config changes

Briana,

Glad you found this useful. The auto Scaffold Module installs and runs without any changes to the web.config.
Very handy in a number of hosted scenarios.
I can use some help with the golf module.

Jim

By Jim on   Friday, October 03, 2008 7:48:32 AM

Re: Running Subsonic without web.config changes

Hi Jim, it's been a while...got sidetracked for a bit (um, like 7-8 months:-) Anyhow, I just installed your DNN_Scaffold module and I'm still trying to pick my jaw up. All I can say is WOW!!! I used the subsonic scaffold way back when I first found it and was amazed, but became discouraged after having so much trouble trying to play with DNN. I am absolutely shocked that I just installed one little control and made two tiny changes to the .config and Voila! OMGoodness gracious...I'm still in awe. I just couldn't let the opportunity to tell you how awesome you are for getting this done. I downloaded your other project as well and am about to play with that. All I can say is, "Good News!!". Btw, how's the golf module coming along? I'm still interested in helping out if you need or want some. Take care and thanks again!

By Briana Tarrance on   Saturday, October 04, 2008 1:33:23 AM

Re: Running Subsonic without web.config changes

Not sure why that posted twice...but, sure..would love to help with the module. I'm not a golfer though, I'll have to warn ya. But, I am a quick study! My email is posted with the comment..feel free to contact me anytime on the project.

By Briana Tarrance on   Saturday, October 04, 2008 1:35:07 AM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 

Navigation

Register Login

About Me

Thanks for stopping by. My name is Jim Bonnie and I have been writing software for over 20 years. After building financial data systems for Reuters for nearly 18 years I have started doing contract work and am excited about technology and currently focus on Microsoft solutions. DotNetNuke has helped provide a good introduction to ASP.NET web application development, and I am now starting to branch out into other areas. Data Access techniques and SubSonic is something that I am looking into now. This has helped me get an invitation to speak at Las Vegas at DNN Open Force 07. it was a great time. And I am looking forward to OpenForce08, where I wil be presenting on TDD for DNN.

 

Reading the codebetter blogs and attending a nothing but .net training class with JP Boodhoo helped spark my interest in ALT.NET. I attended the first conference in Austin Texas, and it was amazing to see Scott Guthrie introduce the ASP.NET MVC framework.

Add to Technorati Favorites

View blog top tags

Links

Jim Bonnie's Blog

Jim Bonnie's Blog

Jim Bonnie's Blog