gpt4 book ai didi

c# - 从 azure blob 打开并修改 mdb 文件

转载 作者:行者123 更新时间:2023-12-03 04:09:22 28 4
gpt4 key购买 nike

我在存储 azure blob 中有一个 mdb 文件,我必须读取和修改该文件,而无需使用 C# 中的某些查询下载它,并且我必须在网页中显示信息(javascript、html)。

[ViewItem(nameof(StorageRetriveDB), "Files", "GET - StorageRetriveDB")]
public List<string> StorageRetriveDB([FromUri] string id)
{
List<string> ListboxItems = new List<string>();
string url = "blobname";
var storageAccount =
CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStorageConnectionString-1"]);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(url);
CloudBlockBlob blob = container.GetBlockBlobReference("mydb.mdb");
if (blob.Exists())
{
using (var stream = blob.OpenRead())
{
string connString = @"Driver={Microsoft Access Driver (*.mdb)};Dbq=LINKTOMYAZUREBLOBSTORAGE/mydb.mdb";
using (OdbcConnection connection = new OdbcConnection(connString))
{
connection.Open();
OdbcDataReader reader = null;
OdbcCommand command = new OdbcCommand("SELECT * from tbVariablesMap", connection);
reader = command.ExecuteReader();
while (reader.Read())
{
ListboxItems.Add(reader[0].ToString() + "," + reader[1].ToString() + "," +
reader[2].ToString() + "," + reader[3].ToString());
}
}
}
}

return ListboxItems;
}

connection.Open(); 导致崩溃,在本地数据库中它可以工作,但在 azure blob 存储中它不起作用!

最佳答案

在您的访问数据库连接字符串中,“Dbq”参数应该是 mdb 文件的文件路径。

但是,Azure Blob 存储并不是为此设计的。正如官方所说documentation :

Blob storage is ideal for:

Serving images or documents directly to a browser.
Storing files for distributed access.
Streaming video and audio.
Storing data for backup and restore, disaster recovery, and archiving.
Storing data for analysis by an on-premises or Azure-hosted service.

Objects in Blob storage can be accessed from anywhere in the world via HTTP or HTTPS. Users or client applications can access blobs via URLs, the Azure Storage REST API, Azure PowerShell, Azure CLI, or an Azure Storage client library.

如果您使用的是 Linux 操作系统,那么可能有一个使用 blob 存储的解决方案。您可以mount Blob storage as a file system with blobfuse 。之后,您可以像访问本地文件一样访问blob。但 blobfuse 不保证 100% POSIX 合规性。

<小时/>

另一种可选方法是使用 Azure 文件共享。您可以安装网络驱动程序,然后可以访问其中的文件。

关于c# - 从 azure blob 打开并修改 mdb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57675953/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com