超碰人人人人人,亚洲AV午夜福利精品一区二区,亚洲欧美综合区丁香五月1区,日韩欧美亚洲系列

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

通過asp程序?qū)崿F(xiàn)批量access數(shù)據(jù)庫導(dǎo)入到sql server數(shù)據(jù)庫中

admin
2012年1月31日 9:5 本文熱度 3391
比如access數(shù)據(jù)庫中有a,b,c三個字段,總共有10條數(shù)據(jù),可直接通過asp程序一次性批量導(dǎo)入到sql server數(shù)據(jù)庫中
 

方法一:先將access數(shù)據(jù)庫中的字段綁定到datagrid再將字段插入sql server數(shù)據(jù)庫
 
設(shè)conn1連接ACCESS,conn2連接SQLServer,在SQLServer數(shù)據(jù)庫中已建好與ACCESS數(shù)據(jù)庫相同表名
 
set rs=conn1.execute "select * from 表名"
do while not(rs.eof or rs.bof)
conn2.execute "insert into 表名(a,b,c) values("&rs("a")&","&rs("b")&","&rs("c"))
rs.movenext
loop
 

方法二:沒辦法直接導(dǎo)入,但是可以先建立與access數(shù)據(jù)庫連接
 
從access表中讀出數(shù)據(jù),存在一個數(shù)據(jù)集里,然后再建立與sql數(shù)據(jù)庫的連接,把數(shù)據(jù)集里的數(shù)據(jù)一條條插入到sql的目標(biāo)表中
 
當(dāng)然,這個表必須事先建立
 
要注意的是兩個表之間如果字段類型不同,在插入數(shù)據(jù)時要注意轉(zhuǎn)換類型。
 

函數(shù)
Function   ImportData(strTableName,objConnSource,objConnDestination)    
   
dim   nFieldCount,   iLoop  
dim   rsSource  
dim   rsDestination  
dim   strSQL  
dim   strFuncMessage  
   
set   rsSource   =   CreateObject("ADODB.RecordSet")  
set   rsDestination   =   CreateObject("ADODB.RecordSet")  
   
strFuncMessage   =   ""  
strSQL   =   "select   *   from   "   &   strTableName  
on   error   resume   next  
rsSource.open   strSQL,   objConnSource,adOpenStatic,adLockOptimistic
 
if   err.number   <>   0   then
ImportData   =   -1  
exit   function  
end   if
 
if   objConnSource.Errors.Count   >   0   then  
strFuncMessage   =   strFuncMessage   &   "<br>Message:   ["   &   strTableName   &   "]   Not   found!"  
rsSource.Close  
set   rsSource   =   nothing  
ImportData   =   -1    
else  
strMessage   =   strMessage   &     "<br>Message:Table["   &   strTableName   &   "]   found!   "    
end   if  
   
nFieldCount   =   rsSource.Fields.Count  
redim   preserve   arrFieldNameList(nFieldCount)  
For   iLoop   =   0   to   nFieldCount   -   1  
arrFieldNameList(iLoop)   =   rsSource.Fields(iLoop).Name  
Next  
   
strSQL   =   "delete   from   "   &   strTableName  
objConnDestination.Execute(strSQL)  
strFuncMessage   =   strFuncMessage   &   "<br>Message:   Delete   ["   &   strTableName   &   "]"    
   
rsDestination.Open   strTableName,   objConn,adOpenStatic,adLockPessimistic,   adCmdTable  
   
Do   while   not   rsSource.Eof  
rsDestination.AddNew  
For   iLoop   =   0   to   nFieldCount-1  
rsDestination(arrFieldNameList(iLoop))   =   rsSource(arrFieldNameList(iLoop))  
Next  
RsDestination.Update  
rsSource.MoveNext  
Loop
   
rsSource.Close  
set   rsSource   =   nothing  
rsDestination.Close  
strSQL   =   "select   product_id   from   "   &   strTableName  
rsDestination.Open   strSQL,   objConnSource,adOpenStatic,adLockOptimistic  
iLoop   =   rsDestination.RecordCount    
rsDestination.Close  
set   rsDestination   =   nothing  
ImportData   =   iLoop  
end   function

該文章在 2012/1/31 9:05:21 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved