Click here to Skip to main content
12,078,070 members (48,127 online)

Articles by jim lahey (Tip/Tricks: 12)

Tip/Tricks: 12

RSS Feed
No articles have been posted.
No blogs have been submitted.

Average tips rating: 4.87

Database
General
Posted: 2 Nov 2011   Updated: 6 Nov 2011   Views: 4,420   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
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...
Posted: 27 Jan 2012   Updated: 27 Jan 2012   Views: 2,670   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
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.
C#
General
Posted: 26 Oct 2011   Updated: 30 Oct 2011   Views: 9,830   Rating: 5.00/5    Votes: 11   Popularity: 5.21
Licence: The Code Project Open License (CPOL)      Bookmarked: 10   Downloaded: 0
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...
XML
Serializing
Posted: 19 Jun 2013   Updated: 19 Jun 2013   Views: 14,050   Rating: 4.80/5    Votes: 4   Popularity: 2.86
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
Installing .NET 4.5 breaks serialization to XML
Programming Tips
General
Posted: 14 Feb 2011   Updated: 14 Feb 2011   Views: 1,550   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
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)); ...
Posted: 16 Feb 2011   Updated: 16 Feb 2011   Views: 8,430   Rating: 5.00/5    Votes: 13   Popularity: 5.57
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
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[^]
Posted: 20 Oct 2011   Updated: 20 Oct 2011   Views: 2,620   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
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...
Posted: 8 Nov 2011   Updated: 8 Nov 2011   Views: 7,500   Rating: 4.17/5    Votes: 6   Popularity: 3.27
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
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...
Posted: 21 Nov 2011   Updated: 21 Nov 2011   Views: 4,860   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 5   Downloaded: 0
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:...
Posted: 3 Feb 2012   Updated: 3 Feb 2012   Views: 3,100   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
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[^]
Debug Tips
General
Posted: 25 Oct 2011   Updated: 25 Oct 2011   Views: 5,110   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 5   Downloaded: 0
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...
Work Issues
General
Posted: 1 Nov 2010   Updated: 13 Nov 2010   Views: 5,670   Rating: 0.0 / 5    Votes: 0   Popularity: 0.0
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 0
No reference articles have been posted.

jim lahey
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


Advertise | Privacy | Mobile
Web01 | 2.8.160212.1 | Last Updated 13 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid