Pete Wright's Radio Weblog
Musings on anything and everything, but mainly code!

 

 

29 October 2004
 

You know, it's the little things that make .NET 2.0 so much more whole than the previous versions ever were. Take connection strings for example. In a typical simple app, you'd probably want to store these in app.config (yes, I'm talking Windows Forms here). You'd probably cut and paste string and change the database name from another app, or maybe even sit down and risk typing the whole damn thing in by hand risking errors along the way cos you're bound to catch them as soon as you run the application anyway.

In Whidbey, and C# Express it's a whole lot easier. Just right click on the project, and choose to add a new blank database in. Give the database a name and instantly you end up with a nice fresh app.config file in your project. Open it up, and you'll find something like this

Which rather handily contains the prebuilt connection string, in this case pointing to local SQL Server 2005 database file. But, what about getting that connection string into the application? Do you still need to do that old System.Configuration.Appl.blahblahblah stuff? Nope. The handy auto generated connection string is pretty much all you'll need

string conString = (string) MyApp.Properties.Settings.Value["Connection"];

I know it's trivial, but to me that's just very cool. It's the little touches like that are going to make .NET 2.0 just so much more accessible to newcomers than ever before.


5:09:12 PM    comment []


Click here to visit the Radio UserLand website. © Copyright 2004 Pete Wright.
Last update: 27/11/2004; 12:29:46.
This theme is based on the SoundWaves (blue) Manila theme.
October 2004
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Sep   Nov