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 ......
ʲôÊÇCache¶ÔÏó?
ÄãÔÚÉú³É¸ßÐÔÄÜÍøÂçÓ¦ÓóÌÐòʱËùÓöµ½µÄÒ»¸öÎÊÌâ¾ÍÊÇÐèÒª±ÜÃâÖظ´¡£Ò»¸öCache¶ÔÏóÔÊÐíÔÚËüÃǵÚÒ»´Î±»ÇëÇóʱÔÚÄÚ´æÖлº´æÏȻºó½«±»»º´æµÄ¸±±¾ÓÃÓÚÒÔºóµÄÇëÇó¡£Ê¹Óñ»»º´æµÄ¸±±¾ÔÊÐíÄã±ÜÃâÖؽ¨Âú×ãÒÔÇ°ÇëÇóµÄÐÅÏ¢£¬ÌرðÊÇÄÇЩÿ´Î´´½¨Ê±¶¼ÐèÕ¼ÓÐÃ÷ʾµÄ·þÎñÆ÷ÉϵĴ¦ÀíÆ÷ʱ¼äµÄÃüÁî¡£
³ý»º´æ¸ö±ðÏÈç» ......
1¡¢C/C++³ÌÐòÔ±Çë×¢Ò⣬²»ÄÜÔÚcaseÓï¾ä²»Îª¿Õʱ“ÏòÏÂÖ´ÐД¡£
2¡¢ÖµÀàÐͺÍÒýÓÃÀàÐÍÖ®¼äµÄÇø±ð£ºC#µÄ»ù±¾ÀàÐÍ£¨int£¬charµÈ£©¶¼ÊÇÖµÀàÐÍ£¬ÊÇÔÚÕ»Öд´½¨µÄ¡£¶ø¶ÔÏóÊÇÒýÓÃÀàÐÍ£¬´´½¨ÓÚ¶ÑÖУ¬ÐèҪʹÓùؼü×Önew¡£
3¡¢ÔÚC#ÖÐͨ¹ýʵÀý·ÃÎʾ²Ì¬·½·¨»ò³ÉÔ±±äÁ¿ÊDz»ºÏ·¨µÄ£¬»áÉú³É±àÒëÆ÷´íÎó¡£µ«ÊÇÎÒÃÇ¿ÉÒÔͨ¹ýÉùÃ÷ËûÃÇ ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;//CryptographyÃÜÂëÊõ
namespace DAL
{
public class Enc ......