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

问题描述:

有什么办法通过asp.net将数据(不一定是模式)导出到访问数据库?将SQL数据库导出到Access - ASP.NET

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

你必须以编程方式做到这一点。

  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 

这是一篇非常详细的文章。这是我偶然发现,没有办法我所熟悉的:

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

+0

恩,我需要将sql数据导出到访问数据库中。您提到的文章似乎是关于上传文件并将其存储在访问数据库中。 – 2008-10-29 10:07:38