How can I read an Access file (.accdb) from a stream?

后端 未结 1 1030
傲寒
傲寒 2020-12-04 03:35

I asked two similar questions:

  • Use OLEDB to read AccessFile from Stream to DataSet

  • Read Microsoft Access File(.accdb) by OpenXML SDK

相关标签:
1条回答
  • 2020-12-04 04:13

    Under the hood Access Databases rely heavily on file usage. Unlike in-memory database such as SQLLite, Access Db's need a file. Hence you'll have to work with the file using OLEDB, OPENXML or via the Object Model.

    Since .Net 4. Streams have a CopyTo method you can use to convert the stream into a temporary accdb file.

    string tempFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\temp.accdb";
    using (var fileStream = File.Create(tempFilePath)
    {
        accDbStream.InputStream.CopyTo(fileStream);
    }
    
    0 讨论(0)
提交回复
热议问题