您的位置:程序门 -> .net技术 -> vb.net



excel导入到sqlserver问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


excel导入到sqlserver问题
发表于:2007-03-07 17:11:31 楼主
我需要把一个excel导入到sqlserver一个表中,如temptable。excel文件在本机不在sqlserver服务器,如果有dataset   只能一行行取很慢。没有又快有好方法!!
发表于:2007-03-07 17:18:381楼 得分:0
insert   表名(字段名.......)

select   *  
from   opendatasource(   'microsoft.jet.oledb.4.0 ',  
  'data   source= "c:\test.xls ";user   id=admin;password=;extended  
properties=excel   5.0 ')...xactions
发表于:2007-03-07 17:25:362楼 得分:0
insert   表名(字段名.......)

select   *
from   opendatasource(   'microsoft.jet.oledb.4.0 ',
'data   source= "c:\test.xls ";user   id=admin;password=;extended
properties=excel   5.0 ')...xactions

excel文件不在sqlserver服务器上可以嘛?
发表于:2007-03-08 14:29:283楼 得分:0
把excel拷到sql服务器上,或者在服务器上映射一个驱动器试试."data   source= "c:\test.xls ";注意改这个
发表于:2007-03-08 15:34:244楼 得分:0
不想把excel放到服务器,就从本地取excel。有更好的方法吗?
发表于:2007-03-08 17:40:305楼 得分:0
dim   inexstr   as   string   =   "provider=microsoft.jet.oledb.4.0;data   source= "   &   strexcelname   &   ";extended   properties= " "excel   8.0;hdr=yes;imex=1 " " "
                dim   inexoledbcon   as   new   oledb.oledbconnection(inexstr)
                dim   inexolead   as   new   oledb.oledbdataadapter( "select   *   from   [sortdata$] ",   inexoledbcon)
                dim   inexds   as   new   dataset
                inexolead.fill(inexds)

                dim   inexdataad   as   dbdataadapter
                inexdataad.selectcommand.commandtext   =   "updatesql "
                dim   inexcom   as   new   sqlclient.sqlcommandbuilder(inexdataad)
                inexdataad.updatecommand   =   inexcom.getdeletecommand
                inexdataad.update(inexds)

inexdataad.selectcommand.commandtext   =   "updatesql "   报错没有   “有没   创建实例”



快速检索

最新资讯
热门点击