将SQL数据库导出到Access - ASP.NET

时间:2008-10-29 09:27:35

标签: asp.net sql ms-access

有没有办法通过asp.net将数据(不一定是架构)导出到访问数据库?

服务器没有安装办公室组件,并且该过程必须通过网页进行(如excel导出)。

2 个答案:

答案 0 :(得分:2)

你必须以编程方式进行。

  1. 打开源表
  2. 使用ADO Extensions创建新的AccessDB(如上所示)
  3. 通过读取源架构(CREATE TABLE X ...)
  4. 在AccessDB中创建表
  5. 迭代认为源表在Access表中插入记录
  6. 注意:此处发布的代码来自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
    

答案 1 :(得分:1)

这是一篇非常详细的文章。这是我偶然发现的事情,而不是我熟悉的方法:

File Uploading to Access Database using ASP.NET by Faisal Khan.

相关问题