Archive for the 'C#.NET' Category
6.25.08 Use SqlParameterCollection To Dynamically Build SqlCommand.CommandString category: C#.NET
0
comm

GOAL
Dynamic SQL command generation with proper use of sql parameterization to protect against sql injection and mal-formated queries.

The solution involves sending in a dynamic key->value list as a single JSON serialized string argument to dynamically build either an INSERT or UPDATE sqlCommand with parameterization.

4.24.08 LitJson Patch To Serialize Hashtable/IDictionary Keys of DateTime Type to JSON category: C#.NET
0
comm

Case in point - I want to convert:
DateTime currDate = new DateTime();
Hashtable dateTest = new Hashtable();
dateTest.Add(currDate, "random value");

to be able to serialize as (with the default DateTime format):
{"4/24/2008 12:00:00 AM":"random Value"}

4.22.08 Convert Single Level “XML” To Native C#.NET Object Via Json And Regular Expressions category: C#.NET
0
comm

convert “xml” (aka “slop”) like:
<>114848000000</><amount>0.00</amount><avs_addr>""YARR</avs_addr>to:
{"amount":"0.00","avs_addr":"\"YARR"} while stripping out the completely invalid <> node. This will also consider all node values to be a string.

4.21.08 Convert ADODB RecordSet XML To ADO.NET DataSet Object Natively In C# category: C#.NET
0
comm

Problem: You have a 3rd party API that returns an ADODB XML RecordSet that you need to incorporate in your .NET application.
ADO.NET is completely different than the Legacy ADODB and offers no completely transparent backward compatibility. As per Microsoft’s admission, http://support.microsoft.com/kb/910696, using TlbImp.exe’d legacy ADODB dll’s or those that were included with Visual Studio 2005 [...]

4.17.08 Simple AES (Rijndael) C# Encrypt & Decrypt functions category: C#.NET
0
comm

I simply re-purposed Bobby Derosa’s Triple DES (3DES) Encrypt() and Decrypt() functions to provide a simple and straight-forward way to use AES symmetrical encryption safe for use on such things as UTF-8 and/or HTTP GET string compatibility. I’m using this in ASP.NET AJAX-enabled applications.
I’m only using a 256bit (32byte) key for these example functions.
Encrypt()
public static [...]

0.454s