【发布时间】:2008-10-29 09:27:35
【问题描述】:
有没有办法通过 asp.net 将数据(不一定是架构)导出到 access 数据库?
服务器未安装任何办公组件,该过程必须通过网页进行(如 Excel 导出)。
【问题讨论】:
有没有办法通过 asp.net 将数据(不一定是架构)导出到 access 数据库?
服务器未安装任何办公组件,该过程必须通过网页进行(如 Excel 导出)。
【问题讨论】:
您必须以编程方式进行。
注意:此处发布来自http://www.freevbcode.com/ShowCode.asp?ID=5797 的代码,以防将来链接不再存在
'select References from the Project Menu, choose the COM tab,
'and add a reference to Microsoft ADO Ext. 2.7 for DDL and Security
Public Function CreateAccessDatabase( ByVal DatabaseFullPath As String) As Boolean
Dim bAns As Boolean
Dim cat As New ADOX.Catalog()
Try
'Make sure the folder
'provided in the path exists. If file name w/o path
'is specified, the database will be created in your
'application folder.
Dim sCreateString As String
sCreateString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
DatabaseFullPath
cat.Create(sCreateString)
bAns = True
Catch Excep As System.Runtime.InteropServices.COMException
bAns = False
'do whatever else you need to do here, log,
'msgbox etc.
Finally
cat = Nothing
End Try
Return bAns
End Function
DEMO
====
' If CreateAccessDatabase("F:\test.mdb") = True Then
' MsgBox("Database Created")
' Else
' MsgBox("Database Creation Failed")
' End If
【讨论】:
这是一篇非常详细的文章。这是我偶然发现的,而不是我熟悉的方法:
File Uploading to Access Database using ASP.NET by Faisal Khan.
【讨论】: