有没有办法通过asp.net将数据(不一定是模式)导出到access数据库?
服务器未安装 Office 组件,该过程必须通过网页进行(如 Excel 导出)。
最佳答案
您必须以编程方式执行此操作。
- 打开源表
- 使用 ADO 扩展创建新的 AccessDB(如上所示)
- 通过读取源架构在 AccessDB 中创建表 (CREATE TABLE X ...)
- 迭代认为源表插入Access表中的记录
注意:代码来自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
关于asp.net - 将 SQL 数据库导出到 Access - ASP.NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/246223/