C#ʵÏÖAccessµ¼Èëµ¼³öExcel
Ò»¡¢Access´ÓExcelÖе¼ÈëÊý¾Ý
1.Óõ½µÄExcel±íµÄ¸ñʽ¼°ÄÚÈÝ
ʵÏÖ
OleDbConnection con = new OleDbConnection();
try
{
OpenFileDialog openFile = new OpenFileDialog();//´ò¿ªÎļþ¶Ô»°¿ò¡£
openFile.Filter = ("Excel Îļþ(*.xls)|*.xls");//ºó׺Ãû¡£
if (openFile.ShowDialog() == DialogResult.OK)
{
string filename = openFile.FileName;
int index = filename.LastIndexOf("\\");//½ØÈ¡ÎļþµÄÃû×Ö
filename = filename.Substring(index + 1);
conExcel.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" +
Application.StartupPath + "\\Appdata.mdb";
//½«excelµ¼Èëaccess
//distinct :ɾ³ýexcelÖØ¸´µÄÐÐ.
//[excelÃû].[sheetÃû] ÒÑÓеÄexcelµÄ±íÒª¼Ó$
//where not in : ²åÈë²»ÖØ¸´µÄ¼Ç¼¡£
string sql = "insert into Users2(Óû§±àºÅ,Óû§ÐÕÃû) select distinct * from [Excel 8.0;database=" +
filename + "].[name$] where Óû§±àºÅ not in (select Óû§±àºÅ from Users2) ";
OleDbCommand com = new OleDbCommand(sql, con);
con.Open();
com.ExecuteNonQuery();
MessageBox.Show("µ¼ÈëÊý¾Ý³É¹¦", "µ¼ÈëÊý¾Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
con.Close();
}
¶þ¡¢Accessµ¼³öExcel
OleDbConnection con = new OleDbConnection();
try
{
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = ("Excel Îļþ(*.xls)|*.xls");//Ö¸¶¨Îļþºó׺ÃûΪExcel Î
Ïà¹ØÎĵµ£º
<?xml version="1.0" encoding="utf-8"?>
<LinkLibrary xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Link Cat="aa" Url="aa" Desc="aa" />
<Link Cat="bb" Url="aa" Desc="aa" />
<Link Cat="cc" Url="aa" Desc="aa" />
&l ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserverÉí·ÝÑéÖ¤
//string sqlconn = "ser ......
VC++ÖÐʹÓÃADO·½Ê½²Ù×÷ACCESSÊý¾Ý¿â
×ªÔØ£ºhttp://www.programbbs.com/doc/3078.htm
ADO(ActiveX Data Object)ÊÇMicrosoftÊý¾Ý¿âÓ¦ÓóÌÐò¿ª·¢µÄнӿڣ¬Êǽ¨Á¢ÔÚOLE DBÖ®Éϵĸ߲ãÊý¾Ý¿â·ÃÎʼ¼Êõ£¬¼´Ê¹Äã¶ÔOLE DB£¬COM²»Á˽âÒ²ÄÜÇáËɶԸ¶ADO,ÒòΪËü·Ç³£¼òµ¥Ò×Óã¬ÉõÖÁ±ÈÄãÒÔÍùËù½Ó´¥µÄODBC API¡¢DAO¡¢RDO¶¼ÒªÈÝÒ×ʹÓ㬲¢² ......
Ê×ÏÈдһ¸öÒ³Ãæ£¬ÉÏÃæÒª·ÅÒ»¸öButton
<html>
<head>
<title></title>
</head>
<body>
<input id="Button1" type="button" value="button" />
</body>
</html>
½«Æä±£´ ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;//CryptographyÃÜÂëÊõ
namespace DAL
{
public class Enc ......