Click here to Skip to main content
15,867,835 members

Articles by jim lahey (Tip/Tricks: 12)

Tip/Tricks: 12

RSS Feed

Average article rating:

No articles have been posted.

Average blogs rating:

No blogs have been submitted.

Average tips rating: 4.87

.NET
16 Feb 2011   Updated: 16 Feb 2011   Rating: 5.00/5    Votes: 13   Popularity: 5.40
Licence: CPOL    Views: 18,380     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
Or you could just pop over to:http://www.connectionstrings.com/[^]Use the exhaustive samples they provide and not hard code your connection strings by using a standard .NET configuration file:http://msdn.microsoft.com/en-us/library/1xtk877y.aspx[^]
Database Development
27 Jan 2012   Updated: 27 Jan 2012   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 6,360     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Please see my alternative tip #2:Do the same thing with SMO[^]There's a Microsoft API for all this, it's been around for a while.
SQL Server
2 Nov 2011   Updated: 6 Nov 2011   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 9,870     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
As a C# developer, I much prefer to perform this kind of task with SMO. The API is really nicely structured and gives quick, strongly-typed access to the nuts and bolts of SQL Server.Using SQL 2008 and Visual Studio 2010, you need to add the following references from C:\Program...
General
1 Nov 2010   Updated: 13 Nov 2010   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 9,710     Bookmarked: 3   Downloaded: 0
Please Sign up or sign in to vote.
Programming Languages
C#
26 Oct 2011   Updated: 30 Oct 2011   Rating: 5.00/5    Votes: 11   Popularity: 5.21
Licence: CPOL    Views: 23,441     Bookmarked: 10   Downloaded: 0
Please Sign up or sign in to vote.
In response to Adrian Cole's comment to the OP - due to living and working in a country where there are four official languages, plus English as a de facto fifth, I've encountered this before.Provided you have the corresponding .resx files embedded in the same assembly as the enum and your...
14 Feb 2011   Updated: 14 Feb 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 4,620     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
I prefer something a little more generic:public static IEnumerable Convert(string value, char separator) where TTypeConverter : TypeConverter { var typeConverter = (TTypeConverter)TypeDescriptor.GetConverter(typeof(TValue)); ...
20 Oct 2011   Updated: 20 Oct 2011   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 7,370     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
I prefer to use ToTraceString() on the ObjectQuery:http://msdn.microsoft.com/en-us/library/system.data.objects.objectquery.totracestring.aspx[^]It's less intrusive as I don't have to instantiate and dispose the StreamWriter and I have more control over where and how I log the resultant...
8 Nov 2011   Updated: 8 Nov 2011   Rating: 4.17/5    Votes: 6   Popularity: 3.24
Licence: CPOL    Views: 18,791     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
You can do the same using the configuration-specific parts of the .NET Framework to save some of the hard work:// Get the configuration file.System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);//Initialize the Connection...
21 Nov 2011   Updated: 21 Nov 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 8,961     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
Please note I don't want to take anything away from roosrj's tip which displays infinitely more in depth knowledge about the SMTP protocol than I can - as a lazy man's alternative I've always used PostCast v2.6 to test anything mail related:...
3 Feb 2012   Updated: 3 Feb 2012   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 6,310     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
While it's a good idea to provide more readable enum values, I'm not keen on this solution because it uses hard-coded values and isn't localizable.Please see my alternative tip on using extension methods and resource files to bind localized strings to enum values:Enum Display Extension[^]
25 Oct 2011   Updated: 25 Oct 2011   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 9,950     Bookmarked: 5   Downloaded: 0
Please Sign up or sign in to vote.
Along similar lines to KeithAMS, when writing a Windows service, I only use the Windows Service Project as a container to run code that is in one or more referenced assemblies. As far as I'm concerned, if I've got any logic that goes beyond starting and stopping the service in my service...
XML
19 Jun 2013   Updated: 19 Jun 2013   Rating: 4.80/5    Votes: 4   Popularity: 2.89
Licence: CPOL    Views: 33,572     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
Installing .NET 4.5 breaks serialization to XML

Average reference rating:

No reference articles have been posted.

Average project rating:

No projects have been posted.
Software Developer (Senior)
United Kingdom United Kingdom
First batch file in 1987

Messed around with the Bullfrog C++ Libraries for Syndicate in 1994

Web Developer since 2000

.net Developer since 2001

MCTS: Microsoft® .NET Framework 2.0 - Web-based Client Development

MCTS: Web Applications Development with Microsoft .NET Framework 4