【问题标题】:Export SQL database to Access - ASP.NET将 SQL 数据库导出到 Access - ASP.NET
【发布时间】:2008-10-29 09:27:35
【问题描述】:

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

服务器未安装任何办公组件,该过程必须通过网页进行(如 Excel 导出)。

【问题讨论】:

    标签: asp.net sql ms-access


    【解决方案1】:

    您必须以编程方式进行。

    1. 打开源表
    2. 使用 ADO 扩展创建新的 AccessDB(如上所示)
    3. 通过读取源模式在 AccessDB 中创建表 (CREATE TABLE X ...)
    4. 迭代认为源表将记录插入 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
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 呃,我需要将sql数据导出到access数据库中。您提到的文章似乎是关于上传文件并将其存储在访问数据库中。
      • 我曾设想从 mssql 表导出到 CSV。但是,我很可能错过了整个要点。 :)
      猜你喜欢
      • 1970-01-01
      • 2016-03-06
      • 2011-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多