上傳Excel檔案並匯入到資料

2021-04-13 04:50:44 字數 1104 閱讀 9018

上傳檔案:

///

/// 上傳excel檔案

///

///

///

protected void btnfileload_click(object sender, eventargs e)

}catch (exception ex)

}else

}匯入檔案:

///

/// 將excel中的檔案匯入到資料庫

///

///

///

protected void btninsertdata_click(object sender, eventargs e)

{//先將excel匯入到資料庫,一:先把excel匯入dateview,二:然後將dateview裡的資料匯入到資料庫裡面

//excel連線

string conn = "provider=microsoft.jet.oledb.4.0;" + "data source=www/excelfile/levovoexcel.xls;" + "extended properties=excel 8.0;";

oledbconnection thisconnection = new oledbconnection(conn);

thisconnection.open();

string sql = "select * from [sheet1$]";

oledbdataadapter mycommand = new oledbdataadapter(sql, thisconnection);

dataset ds = new dataset();

mycommand.fill(ds, "[sheet1]");

thisconnection.close();

//sql連線

sqlconnection thisconnection1 = new sqlconnection(sqlhelper.conn_default);

thisconnection1.open();

int count = ds.tables["[sheet1]"].rows.count;

Excel資料匯入到Grid

方法一 string strcon provider microsoft.jet.oledb.4.0 data source strsource extended properties excel 8.0 string query select from sheet1 sheet1表示表 oledb...

Excel資料匯入到Access

下面是asp的全部程式,需要做的是建乙個test.mdb資料庫和乙個test.xls的excel 查詢excel準備匯入到access sql select from sheet1 要匯入的excel資料裡面的表的名稱,後面一定要加 set rs conn2.execute sql while no...

Excel資料匯入到oracle

excel資料匯入到oracle 第一步 將要匯入的excel檔案開啟,選擇 另存為 在檔案型別那裡選擇 文字.txt 後確定儲存 第二步 開啟記事本,編寫下列的內容 注釋 1 控制檔案標識 2 剛才由excel檔案轉化過來的檔案的路徑 3 向oracle的資料表t network agent ba...