• 全部
  • 问答

有关execl如何导入access的语句如何写?

zigine 2003-05-07 06:46:34
set rs = Server.CreateObject("ADODB.Recordset")
sql="insert into onsale in 'e:\gllin\xmlfjjt\xmlf\house\book1.xls' 'EXCEL 5.0'"
rs.open Sql,mycon,1,1
行不,请帮忙
...全文
27 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
btone 2003-05-07
说明:窗体上控件如下:第一行:label:电子表格 文本框 (输入Excel绝对地址)
第二行:label:数据库 文本框 (输入要转换为mdb的地址和名称) 第三行: 加载数据按钮!


我曾经用过的程序,把Excel转为mdb数据库,供你借鉴!
回复
btone 2003-05-07

Option Explicit

Private Sub cmdLoad_Click()
Dim excel_app As Object
Dim excel_sheet As Object
Dim db As Database
Dim new_value As String
Dim row As Integer

Screen.MousePointer = vbHourglass
DoEvents

' Create the Excel application.
Set excel_app = CreateObject("Excel.Application")

' Uncomment this line to make Excel visible.
' excel_app.Visible = True

' Open the Excel spreadsheet.
excel_app.Workbooks.Open FileName:=txtExcelFile.Text

' Check for later versions.
If Val(excel_app.Application.Version) >= 8 Then
Set excel_sheet = excel_app.ActiveSheet
Else
Set excel_sheet = excel_app
End If

' Open the Access database.
Set db = OpenDatabase(txtAccessFile.Text)

' Get data from the Excel spreadsheet and insert
' it into the TestValues table.
row = 1
Do
' Get the next value.
new_value = Trim$(excel_sheet.Cells(row, 1))

' See if it's blank.
If Len(new_value) = 0 Then Exit Do

' Insert the value into the database.
db.Execute "INSERT INTO TestValues VALUES (" & _
new_value & ")"

row = row + 1
Loop

' Close the database.
db.Close
Set db = Nothing

' Comment the rest of the lines to keep
' Excel running so you can see it.

' Close the workbook without saving.
excel_app.ActiveWorkbook.Close False

' Close Excel.
excel_app.Quit
Set excel_sheet = Nothing
Set excel_app = Nothing

Screen.MousePointer = vbDefault
MsgBox "Copied " & Format$(row - 1) & " values."
End Sub

' Note that this project contains a reference to
' Microsoft DAO 3.51 Object Library.
Private Sub Form_Load()
Dim file_path As String

file_path = App.Path
If Right$(file_path, 1) <> "\" Then file_path = file_path & "\"
txtExcelFile.Text = file_path & "XlsToMdb.xls"
txtAccessFile.Text = file_path & "XlsToMdb.mdb"
End Sub

回复
zigine 2003-05-07
有什么办法可以解决
回复
changechange 2003-05-07
不行!
回复
发帖
Access
创建于2007-09-28

7496

社区成员

Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
申请成为版主
帖子事件
创建了帖子
2003-05-07 06:46
社区公告
暂无公告