December 2007 Entries
Ok, I usually try to only talk about best practices but sometimes we all need a quick an dirty few lines to execute a stored procedure, no Enterprise Data Access, no LINQ, just System.Data and the managed provider for our given DB. Well here goes.
1 //get the config info from the app.config file
2 ConnectionStringSettings myConnectionSettings = ConfigurationManager.ConnectionStrings["ConnectionKey"];
3 DbProviderFactory myProvider = DbProviderFactories.GetFactory(myConnectionSettings.ProviderName);
5 using (DbConnection myConnection = myProvider.CreateConnection())
6 using (DbCommand myCommand = myProvider.CreateCommand())
8 // Get the connection string from the connectionsettings
Our original plan for Day of Silverlight was to have Jesse Liberty from the Silverlight product team come down and fill us in on all things Silverlight. After lunch sponsored by KFoce (http://www.kforce.com). We planed to close the day out with a presentation by John Papa on WPF. Well the gods must not have been smiling on us because on the Tuesday before the event I got a frantic email from Bill Reiss (https://mvp.support.microsoft.com/profile/Bill.Reiss) telling me to read Jesse's blog (http://silverlight.net/blogs/jesseliberty/archive/2007/12/10/did-you-know-1-if-you-fall-on-black-ice-you-can-dislocate-your-shoulder.aspx). After a few emails with Jesse I learned that he would have to cancel due to the fact that...
Like any good developer, when someone comes to my desk and says you cannot do something I have to prove them wrong. This was one of those challenges. He said you cannot “generate, compile and execute code on the fly in .NET”. I said yes you can, he said no you cannot and after five minutes of back and forth I decided to throw together this example.
Step 1: Build the codeHere you have 2 options: code as strings, code from CodeDom. What one you pick depends on what you are doing. In “Programming Microsoft ASP.NET 2.0 Applications Advanced Topics by...
When attempting to call a webservice that lives outside my corperate firewall I was getting the following error:
System.Net.WebException was unhandled by user code Message="Unable to connect to the remote server" Source="System" StackTrace: at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object parameters)
After some research I stumbled across this post by Rick Strahlhttp://west-wind.com/weblog/posts/3871.aspx
but my problem was a little bit different. In his case he desired to disable to the automatic proxy detection, but I needed to wire in the script that my corperate IT department requires that we use. Easy enough just add the following to the web.config
<system.net> <defaultProxy> <proxy scriptLocation ="url to script here" /> </defaultProxy> </system.net>