ASP.NETµÄACCESSÊý¾Ý¿â²Ù×÷Àà
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//Êý¾Ý¿âµØÖ·
private string datapatch = "db/global.asa";//Êý¾Ý¿âµØÖ·
///
/// È¡µÃdataset
//
/// ²éѯÓï¾ä
///
public DataSet GetDataSet(string Commandtext)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath(datapatch);
string strCommandText = Commandtext;
OleDbConnection myConnection = new OleDbConnection(strConnection);
myConnection.Open();
OleDbDataAdapter myAdpater = new OleDbDataAdapter(strCommandText,myConnection);
OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdpater);
DataSet myDataset = new DataSet();
myAdpater.Fill(myDataset);
myConnection.Close();
return myDataset;
}
///
/// È¡µÃ±í
///
/// ²éѯÓï¾ä
///
public DataTable GetDataTable(string Commandtext)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath(datapatch);
string strCommandText =Commandtext;
OleDbConnection myConnection = new OleDbConnection(strConnection);
myConnection.Open();
OleDbDataAdapter myAdpater = new OleDbDataAdapter(strCommandText,myConnection);
OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdpater);
DataSet myDataset = new DataSet();
myAdpater.Fill(myDataset);
DataTable mytable = myDataset.Tables[0];
myConnection.Close();
return mytable;
}
///
/// È¡µÃijÐеÄijÁеÄÖµ
///
/// ÁеÄÃû³Æ
/// ËùÊô±íÃû
/// ±íµÄÖ÷¼ü
/// ÁÐËùÊôµÄÖ÷¼üÖµ
///
public string GetDataColum(string strColumnName,string strTableName,string strColumnkey,string strColumnValue)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " +
Ïà¹ØÎĵµ£º
×Ô¼º×öµÄÒ»¸ö.net´íÎóÊÕ¼¯£¬ÊÕ¼¯ÕûÕ¾µÄ500´íÎó£¬ÓõÄaccessÊý¾Ý¿â¡£Êý¾Ý¹ý20000ºó£¬Ê¹Óô«Í³µÄSELECT TOP 10 * from TABLE WHERE ID NOT IN(SELECT TOP 10*10 * from TABLE)²éѯ¾¹È»ÒªºÃ¼¸·ÖÖÓ£¬º¹~~~~£¡
ÍøÉϲ鵽µÄÒ»ÌõÓï¾ä»¹²»´í¡£
SELECT TOP 10 id,Message,CreateTime ......
Sql´úÂë
--²ÉÓÃSQLÓï¾äʵÏÖsql2005ºÍExcel Êý¾ÝÖ®¼äµÄÊý¾Ýµ¼Èëµ¼³ö£¬ÔÚÍøÉÏÕÒÀ´Ò»--Ï£¬ÊµÏÖ·½·¨ÊÇÕâÑùµÄ£º
--Excel---->SQL2005 µ¼È룺
select * into useinfo from O ......
using System.Data.OleDb; //ÕâÀïÒªÒýÓÃOleDb¿Õ¼ä
public partial class addInfo : System.Web.UI.Page
{
//Êý¾Ý¿âÁ¬½Ó×Ö·û´®
static string strCon = @"provider = Microsoft.Jet.OLEDB.4.0;Data source = |DataDirectory|gyMDB.mdb";
//ÒÔÉÏ·½·¨ÎªÁ¬½ÓACC ......
Õ⼸Ìì°ïͬѧ×öÒ»¸öСµÄ¹ÜÀíϵͳ£¬B/S½á¹¹µÄ£¬ÓÉÓںܾÃûÓÐ×öB/S½á¹¹µÄ¶«Î÷ÁË£¬×öµÄʱºòºÜÉúÊè¡£Ò»¸öÏÂÎ磬Óöµ½ÁËÒ»¸öÎÊÌ⣺ÍùAccessÀï²åÈëÊý¾ÝµÄʱºò£¬ÀÏÊÇÌáʾÎÒsqlÓï¾ä´íÎ󣬵«ÊǾͺÜÄÉÃÆÁË£¬ÕâÖÖsqlÓï¾äдÁ˲»ÏÂ500±éÁË°É£¬¾ÍËãÊÇ×öÃÎÒ²²»»áд´íµÄ£¬Ôõô»ØÊ£¿sqlÓï¾ ......
Ê×Ò³£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head ......