using System;using System.Collections;
using System.Data;using System.Reflection;
using System.Collections.Generic;
using System.Text;
public static class Util
{
public static DataTable ConvertArrayListToDataTable(ArrayList arrayList)
{
DataTable dt = new DataTable();
if (arrayList.Count != 0)
{
dt = ConvertObjectToDataTableSchema(arrayList[0]);
FillData(arrayList, dt);
}
return dt;
}
public static DataTable ConvertObjectToDataTableSchema(Object o)
{
DataTable dt = new DataTable();
PropertyInfo[] properties = o.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
DataColumn dc = new DataColumn(property.Name);
dc.DataType = property.PropertyType; dt.Columns.Add(dc);
}
return dt;
}
private static void FillData(ArrayList arrayList, DataTable dt)
{
foreach (Object o in arrayList)
{
DataRow dr = dt.NewRow();
PropertyInfo[] properties = o.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
dr[property.Name] = property.GetValue(o, null);
}
dt.Rows.Add(dr);
}
}
}
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Thursday, May 15, 2008
Friday, October 26, 2007
.NET Videos
Educational Videos for .NET
Dot Net Rocks!
Learn Visual Studio
Channel 9
Learn ASP.NET
Windows Client.NET
Dot Net Rocks!
Learn Visual Studio
Channel 9
Learn ASP.NET
Windows Client.NET
Wednesday, October 17, 2007
Working with Oracle and ASP.NET 2.0
The Oracle Client with Enterprise Manager for remote administration
http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10201winsoft.html has the Oracle 10g Client. Choose ‘Administrator’ during installation to include the client and Enterprise Manager.
Oracle Express Database for local development / testing
Local installation should be the Oracle Express version for free at: http://www.oracle.com/technology/software/products/database/xe/index.html
Oracle SQL Developer for database design
http://www.oracle.com/technology/products/database/sql_developer/index.html
http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10201winsoft.html has the Oracle 10g Client. Choose ‘Administrator’ during installation to include the client and Enterprise Manager.
Oracle Express Database for local development / testing
Local installation should be the Oracle Express version for free at: http://www.oracle.com/technology/software/products/database/xe/index.html
Oracle SQL Developer for database design
http://www.oracle.com/technology/products/database/sql_developer/index.html
Friday, October 12, 2007
Oracle SQL and C# Dates
If you are working with Oracle and C#, you may need to insert a Date into the database. The way this is done, is to specifiy a date format and then let Oracle know what the format is by using the "to_date" function. One of the problems is that C# and Oracle specifiy date formats differently.
Here is one example:
strFromDate = myFromDate.ToString("MM/dd/yyyy hh:mm:ss tt");
strToDate = myToDate.ToString("MM/dd/yyyy hh:mm:ss tt");
_sqlQuery += "AND DATE_COMPLETED >= to_date('" + strFromDate + "', 'MM/DD/YYYY HH:MI:SS PM') ";
_sqlQuery += "AND DATE_COMPLETED <= to_date('" + strToDate + "', 'MM/DD/YYYY HH:MI:SS PM') ";
Here is one example:
strFromDate = myFromDate.ToString("MM/dd/yyyy hh:mm:ss tt");
strToDate = myToDate.ToString("MM/dd/yyyy hh:mm:ss tt");
_sqlQuery += "AND DATE_COMPLETED >= to_date('" + strFromDate + "', 'MM/DD/YYYY HH:MI:SS PM') ";
_sqlQuery += "AND DATE_COMPLETED <= to_date('" + strToDate + "', 'MM/DD/YYYY HH:MI:SS PM') ";
Wednesday, October 10, 2007
C# Back Button - Server Side (Not Javascript)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["originalUrl"] = Request.UrlReferrer.AbsoluteUri;
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
Response.Redirect(ViewState["originalUrl"].ToString(), false);
}
Subscribe to:
Posts (Atom)
Check This Out!
More Links to Good Information
- January (1)
- December (1)
- August (1)
- April (1)
- February (1)
- December (1)
- October (1)
- January (1)
- September (1)
- February (2)
- January (2)
- May (3)
- February (1)
- May (1)
- October (1)
- January (1)
- August (1)
- March (1)
- May (1)
- March (1)
- January (1)
- March (1)
- December (2)
- September (2)
- June (1)
- February (1)
- January (1)
- October (1)
- December (2)
- November (1)
- August (4)
- July (14)
- June (10)
- May (9)
- April (2)
- February (4)
- January (2)
- December (7)
- October (10)