[ת]C#.net±à³Ì´´½¨ Access ÎļþºÍ Excel Îļþ
һЩϵͳ¿ÉÄÜÐèÇó°ÑÊý¾Ýµ¼³öµ½Access»òÕßExcelÎļþ¸ñʽ£¬ÒÔ·½±ãµÄ´«µÝÊý¾Ý¡¢´òÓ¡µÈ¡£
Excel Îļþ»òÕß AccessÕâÁ½ÖÖÐèÒªµ¼³öµÄÎļþ¿ÉÄܲ¢²»ÊÇÊÂÏȾʹæÔڵģ¬Õâ¾ÍÐèÒªÎÒÃÇ×Ô¼º±à³ÌÉú³ÉËûÃÇ£¬ÏÂÃæÕûÀíÒ»ÏÂÉú³ÉÕâÁ½¸öÎļþµÄһЩ·½·¨£¬Ö»ÂÞÁÐ×î³£Óõġ£²¢²»È«¡£
Ò»¡¢Ê×ÏÈÉú³ÉExcelÎļþ¡£
·½°¸Ò»¡¢Èç¹ûÓÃExcel±£´æµÄÖ»ÊǶþάÊý¾Ý£¬Ò²¾ÍÊǰÑËûµ±Êý¾Ý¿âµÄÀ´Óá£
×î¼òµ¥£¬Äã²»ÓÃÒýÓÃÈκζîÍâ×é¼þ£¬Ö»ÐèÒªÓà OLEDB ¾Í¿ÉÒÔÍê³É´´½¨ExcelÎļþ¡£ ·¶Àý´úÂëÈçÏ¡£
using System.Data.OleDb;
public static void CreateExcelFile2()
{
string OLEDBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\aa2.xls;";
OLEDBConnStr += " Extended Properties=Excel 8.0;";
string strCreateTableSQL = @" CREATE TABLE ";
strCreateTableSQL += @" ²âÊÔ±í ";
strCreateTableSQL += @" ( ";
strCreateTableSQL += @" ID INTEGER, ";
strCreateTableSQL += @" UserID INTEGER, ";
strCreateTableSQL += @" UserIP VARCHAR , ";
strCreateTableSQL += @" PostTime DATETIME , ";
strCreateTableSQL += @" fromParm VARCHAR ";
strCreateTableSQL += @" ) ";
OleDbConnection oConn = new OleDbConnection();
oConn.ConnectionString = OLEDBConnStr;
OleDbCommand oCreateComm = new OleDbCommand();
oCreateComm.Connection = oConn;
oCreateComm.CommandText = strCreateTableSQL;
oConn.Open();
oCreateComm.ExecuteNonQuery();
oConn.Close();
}
using System.Data.OleDb;
public static void CreateExcelFile2()
{
string OLEDBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\aa2.xls;";
OLEDBConnStr += " Extended Properties=Excel 8.0;";
string strCreateTableSQL = @" CREATE TABLE ";
strCreateTableSQL += @" ²âÊÔ±í ";
strCreateTableSQL += @" (
Ïà¹ØÎĵµ£º
ǰÌâÊDZØÐë°²×°ºÃactiveperl £¨505ÒÔÉÏ£©£¬ÒÔ¼°MS Access 97
¡¡¡¡
¡¡¡¡Ò».
°²×°Win32-ODBCÄ£¿é
¡¡¡¡²½Öè1£º
¡¡¡¡´ÓTOOLSÀ¸Ä¿ÖÐÏÂÔØWin32-ODBC.zip,ÏÂÔØÍêºóÓÃwinzip½â¿ªµ½Ò»¸ötempĿ¼,¹²ÓÐÈý¸öÎļþ£º
¡¡¡¡Readme
¡¡¡¡Win32-ODBC.ppd
¡¡¡¡Win32-ODBC.tar.gz
¡¡¡¡²½Öè2£º
¡¡¡¡ÔÚDOS´°¿ÚÏ£¬tempĿ¼ÖÐÔËÐÐÏÂÃæµÄD ......
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Óï¾ ......
·¢²¼ÈÕÆÚ : 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 Ó¦ÓÃ³Ì ......
1£¬´ò¿ª”¿ØÖÆÃæ°å“Ï”¹ÜÀí¹¤¾ß“ÖеĔÊý¾Ý¿âÔ´“£»
2£¬°´”Ìí¼Ó“Ìí¼ÓÒ»¸öеÄÊý¾ÝÔ´£¬ÔÚÑ¡ÔñÀ¸ÀïÑ¡“Driver do microsoft Access (*.mdb)”£¬Íê³Éºó½«³öÏÖÒ»¸ö¿ò£¬ÔÚ“Êý¾Ý¿âÔ´”ÀïÃæÊäÈëÄãÏëдµÄÃû³Æ£¬ÎÒÈ¡Ãû½Ð“ABC”£¬ËµÃ÷²»ÐèÒªÌ½Ó×Å ......