CodeKeep C# Feed Gennaio 22nd, 2008
Description: Lists all of the SQL Server data types that are available
Link:
http://www.codekeep.net/snippets/7932698a-e718-4188-8d07-d07f5e6621ad.aspxforeach (string s in Enum.GetNames(typeof(System.Data.SqlDbType))) {
Console.WriteLine(s);
}
CodeKeep C# Feed Gennaio 22nd, 2008
Description: This method allows you to add DataRows and have them call the implemented method on that inherits Collectoin Wrapper to add it as a child object.
Link:
http://www.codekeep.net/snippets/5ea6a925-0a93-48e3-a5d2-b62ea921a234.aspx /// <summary>
/// Accepts a collectionwrapper object defined by the collection wrapper generic and loads
/// the appropriate data from a dataset into the collection, creating child items in the collection
/// for every data row that cooresponds.
/// </summary>
/// <typeparam name="T">The type of collection wrapper you wish to load.</typeparam>
/// <typeparam name="T">The type of items within the collection.</typeparam>
/// <param name="Collection">The collection wrapper that is implemented and whose Load method is called.</param>
/// <param name="Statement">The sql statment or stored procedure name. </param>
/// <param name="Params">The parameters for the sqlstatement / stored procedure.</param>
/// <param name="SQLCommandType">The comman type: either Text or StoredProcedure.</param>
/// <returns></returns>
public static T FillCollectionWrapperObject<T, K>(T Collection, string Statement, SqlParameter[] Params, CommandType SQLCommandType) where T:CollectionWrapper<K>
{
DataSet ds = FillDataset(Statement, Params, SQLCommandType);
if (DataSetHasRows(ds))
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
Collection.AppendItemFromDataRow(dr);
}
}
else { Collection = null; }
return Collection;
}
}