Data Access Application Block
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
Database db = DatabaseFactory.CreateDatabase("NorthWind");
// Database db = DatabaseFactory.CreateDatabase();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.GridView1.DataSource = GetDateSet("select top 10 * from dbo.Products").Tables[0];
this.GridView1.DataBind();
}
}
/// <summary>
/// Ö´Ðе¥ÌõSQL Óï¾ä
/// </summary>
/// <param name="sql">sql</param>
/// <returns>DataSet</returns>
private DataSet GetDateSet(string sql)
{
DataSet ds = db.ExecuteDataSet(CommandType.Text,sql);
return ds;
}
/// <summary>
/// Ö´Ðе¥ÌõSQL Óï¾ä——Ö»¶ÁÊý¾Ý
/// </summary>
/// <param name="sql">sql</param>
/// <returns>IDataReader</returns>
private IDataReader GetDataReader(string sql)
{
IDataReader idatareader = db.ExecuteReader(CommandType.Text,sql);
return idatareader;
}
/// <summary>
/// Ö´Ðе¥ÌõSQL Óï¾ä——»ñµÃÒ»ÁÐÊý¾Ý
/// </summary>
/// <param name="sql">sql</param>
/// <returns>int</returns>
private int GetSingleValue(string sql)
{
int value =(int)db.ExecuteScalar(CommandType.Text,sql);
return value;
}
/// <summary>
/// Ö´Ðд洢¹ý³Ì
/// </summary>
private void ExeProcNonPar()
Ïà¹ØÎĵµ£º
ÈÕÆÚ/ʱ¼ä
CDate ½«×Ö·û´®×ª»¯³ÉΪÈÕÆÚ select CDate("2005/4/5")
Date ·µ»Øµ±Ç°ÈÕÆÚ
DateAdd ½«Ö¸¶¨ÈÕÆÚ¼ÓÉÏij¸öÈÕÆÚselect dateAdd("d",30,Date())½«µ±Ç°ÈÕÆÚ¼ÓÉÏ30Ìì,ÆäÖÐd¿ÉÒÔ»»Îªyyyy»òHµÈ
DateDiff ÅжÏÁ½¸öÈÕÆÚÖ®¼äµÄ¼ä¸ô select DateDiff("d","2006-5-1& ......
Èí¼þÃû³Æ: EA2A(Excel/Access to Access)
Èí¼þ°æ±¾: beta2
ÊÚȨÐÎʽ: Ãâ·ÑÈí¼þ
ÔËÐÐƽ̨: Win9x/Me/NT/2000/XP/2003
Êý¾Ý¿âÉý¼¶ºóÔÓбíÖÐ×ֶλáÔö¼Ó£¬´ËʱÎÒÃǾÍÐèÒªµ¼È루ǨÒÆ£©Êý¾Ý£¬´Ë³ÌÐòΪʵÏִ˹¦Äܶø±àд¡£
ͨ³£Èí¼þÉý¼¶ºó£¬Êý¾Ý¿âÒ²»áÓÐËù¸Ä±ä£¬´Ëʱ¾ÍÐèÒª¶Ô¿Í»§Ê¹ÓõÄÊý¾Ý¿â½øÐÐÉý¼¶¡£Éý¼¶¿Í»§Êý¾Ý¿âµÄ·½Ê½Ó ......
2008-04-10 09:45 //*******FactoryManage.cs using System;
using System.Reflection;
using System.Configuration;
using CoalTraffic.IDAL; namespace CoalTraffic.DALFactory
{
/// <summary>
/// ³éÏ󹤳§Ä£Ê½´´½¨DAL¡£
......
Oracle Êý¾Ý¿â 10g ÌṩÁË´óÁ¿°ïÖú³ÌÐò£¨»ò“¹ËÎʳÌÐò”£©£¬¿É°ïÖúÄú¾ö¶¨×î¼Ñ²Ù×÷Á÷³Ì¡£ÆäÖÐÒ»¸öʾÀýÊÇ SQL Tuning Advisor£¬Ëü¿ÉÒÔÌṩÓйزéѯµ÷ÕûÒÔ¼°ÔÚÁ÷³ÌÖÐÑÓ³¤Õû¸öÓÅ»¯¹ý³ÌµÄ½¨Òé¡£
µ«Ç뿼ÂÇÒÔϵ÷Õû°¸Àý£º¼ÙÉèÒ»¸öË÷ÒýȷʵÓÐÖúÓÚij¸ö²éѯ£¬µ«¸Ã²éѯִֻÐÐÒ»´Î¡£ÕâÑù£¬¼´Ê¹¸Ã²éѯ¿ÉÒÔµÃÒæÓÚ´ËË÷Òý£¬µ«´´ ......
/*
--×÷ÓãºSQL SERVER²Ù×÷ACCESSµÄ´æ´¢¹ý³Ì
----------------------Ó÷¨-------------------------------
--´´½¨±ítc
exec sp_operate_access 'create table tc(id int)','c:\db1.mdb'
go
--ÔÚtc±í²åÈëÊý¾Ý
exec sp_operate_access 'insert into tc(id) values(1)','c:\db1.mdb'
go
--ɾ³ýtc±íµÄÊý¾Ý
exec sp_op ......