如何使用vb.net将Excel工作表或Open Office导入访问数据库 [英] how to import the excel sheet or Open office into access database using vb.net

查看:174
本文介绍了如何使用vb.net将Excel工作表或Open Office导入访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,我对winforms有要求,我会将excel表或打开办公室文件导入访问数据库。我写了excel中的代码来访问数据库。如果excel不在那里,客户系统中有开放式办公室。任何一个文件都会将文件导入访问数据库。这里访问数据库字段名称和开放式办公室或Excel工作表字段名称应相同,任何版本都应该使用我们的代码。

Hi friends , i have a requirement in winforms, i will import the excel sheet or open office file into access database. i was wrote the code in excel to access database. if excel is not there and open office is there in client system . any one of the file will import the file into access database. Here access database fields names and open office or excel sheet field names should same and any version should work using our code.

Dim connect As String = _
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + _
Excel + ";Extended Properties=""Excel 12.0 Xml;"""

Using conn As New OleDb.OleDbConnection(connect)

    Using cmd As New OleDbCommand()

        cmd.Connection = conn

        'inserting the Excel data to Access database
        cmd.CommandText = "INSERT INTO [MS Access;Database=" & _
           Access & "].[village] SELECT * FROM [" + tableName + "$]"

        conn.Open()

        cmd.ExecuteNonQuery()

    End Using

End Using







请帮助我。

高级谢谢...




Please help me anyone.
advanced thanks...

推荐答案



conn.Open()

cmd.ExecuteNonQuery()

结束 使用

结束 使用







请帮助我。

高级谢谢......




Please help me anyone.
advanced thanks...


http://office.microsoft.com/en-us/excel-help /import-excel-data-to-an-access-database-HP005200852.aspx [ ^ ]


这篇关于如何使用vb.net将Excel工作表或Open Office导入访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆