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()
Ïà¹ØÎĵµ£º
·¢²¼ÈÕÆÚ : 8/8/2003 | ¸üÐÂÈÕÆÚ : 6/7/2004
Martin Tracy
Visual Studio Team
Microsoft Corporation
ÊÊÓÃÓÚ£º Microsoft® ADO.NET
Microsoft® ASP.NET
Microsoft® Visual C#® .NET
Microsoft® Visual Studio® .NET
ÕªÒª£º±¾ÑÝÁ·ËµÃ÷ÁËÈçºÎʹÓüòµ¥µÄ Visual C#® ÄÚº¬´úÂë Web Ó¦ÓÃ³Ì ......
Èí¼þÃû³Æ: EA2A(Excel/Access to Access)
Èí¼þ°æ±¾: beta2
ÊÚȨÐÎʽ: Ãâ·ÑÈí¼þ
ÔËÐÐƽ̨: Win9x/Me/NT/2000/XP/2003
Êý¾Ý¿âÉý¼¶ºóÔÓбíÖÐ×ֶλáÔö¼Ó£¬´ËʱÎÒÃǾÍÐèÒªµ¼È루ǨÒÆ£©Êý¾Ý£¬´Ë³ÌÐòΪʵÏִ˹¦Äܶø±àд¡£
ͨ³£Èí¼þÉý¼¶ºó£¬Êý¾Ý¿âÒ²»áÓÐËù¸Ä±ä£¬´Ëʱ¾ÍÐèÒª¶Ô¿Í»§Ê¹ÓõÄÊý¾Ý¿â½øÐÐÉý¼¶¡£Éý¼¶¿Í»§Êý¾Ý¿âµÄ·½Ê½Ó ......
1£¬´ò¿ª”¿ØÖÆÃæ°å“Ï”¹ÜÀí¹¤¾ß“ÖеĔÊý¾Ý¿âÔ´“£»
2£¬°´”Ìí¼Ó“Ìí¼ÓÒ»¸öеÄÊý¾ÝÔ´£¬ÔÚÑ¡ÔñÀ¸ÀïÑ¡“Driver do microsoft Access (*.mdb)”£¬Íê³Éºó½«³öÏÖÒ»¸ö¿ò£¬ÔÚ“Êý¾Ý¿âÔ´”ÀïÃæÊäÈëÄãÏëдµÄÃû³Æ£¬ÎÒÈ¡Ãû½Ð“ABC”£¬ËµÃ÷²»ÐèÒªÌ½Ó×Å ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â ......
MicrosoftµÄACCESSÊý¾Ý¿â£¬ÊÇÎÒÃdz£ÓõÄ×ÀÃæÊý¾ÝÖ®Ò»£¬´ó¶àÖÐСÆóÒµµÄÊý¾Ý¿â¹ÜÀíϵͳ¶¼¿ÉÒÔ²ÉÓÃËü£¬µ«Æ䰲ȫÐÔÒ»Ö±ÁîÈ˵£ÓÌ£¬ÊÔÏ룬һÌײÆÎñ¹ÜÀíϵͳ£¬Óû§Ö±½Ó´ò¿ªÊý¾Ý¿âÈ¥¸ü¸ÄÊý¾Ý£¬ºó¹û»áÈçºÎ£¿ÓÐЩϵͳ¶ÔACCESSÊý¾Ý¿â¿ÉÄÜÖ»ÊǸü¸ÄÀ©Õ¹Ãû£¬»ò¼Ó¸öÃÜÂ룬ÖÚËùÖÜÖª£¬ÆƽâACCESSÃÜÂëµÄ·½·¨ºÍ¹¤¾ßÍøÉ϶àµÄÊÇ£¡ËùÒÔÕâÑùµÄ¼Óà ......