gpt4 book ai didi

mysql - 通过编程从C#程序附带的数据库中备份数据库

转载 作者:行者123 更新时间:2023-11-29 12:27:25 26 4
gpt4 key购买 nike

当连接字符串类似于

Data Source=IMMENSE-01\\SQLEXPRESS;Initial Catalog=dipar;Integrated Security=True

我可以使用此查询来备份数据库

backup database dipar to disk ='F:\DBBackup\dipar.bak' with init,stats=10

但是当我将数据库与程序一起保存以制作可执行文件时,连接字符串就像

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dipar.mdf;Integrated Security=True;User Instance=True

以及进行备份的查询 backup database dipar to disk ='F:\DBBackup\dipar.bak' with init,stats=10说找不到数据库。

请帮忙

最佳答案

抱歉,我的第一个答案不正确。

If you're using the AttachDbFileName= approach in your connection string, you cannot use BACKUP DATABASE since that database file is not really attached to the SQL Server Express instance. That's one of the many drawbacks and shortcomings of that approach – marc_s

来自:How to create database backup, when DB not stored in Microsoft SQL Server?

关于mysql - 通过编程从C#程序附带的数据库中备份数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28103417/

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