且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数据从Excel工作表导入到SQL Server 2005

更新时间:2022-11-02 20:33:22

u可以从excel表中读取数据,就像您从数据库中读取数据一样.根据Microsoft Office版本,仅连接字符串会更改.

例如,
u can read data from excel sheet in the same way u do from database. Only the connection string will change depending on microsoft office version.

For eg.,
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";


如果不起作用,您可以从以下网站搜索其他人:http://www.connectionstrings.com/excel

然后,对于数据访问查询,表名将是带有"


If it dont work, u can search others from: http://www.connectionstrings.com/excel

Then for data access query, thhe table name will be the sheet name with ''


"符号的工作表名称.例如,假设工作表名称为"Sheet1",查询将为:
'' sign appended. For eg, suppose sheet name is "Sheet1", query will be:
select * from [Sheet1



您可以使用您的数据访问方法(例如OledbConnection和OledbCommand)将数据读入DataTable.之后,使用ur方法,您可以将其插入sql server数据库. :)


U can read data by using your data access method (e.g. OledbConnection and OledbCommand) into DataTable. After that, using ur method, u can insert into sql server database. :)