使用clickonce使用SQL Server数据库进行C#windows应用程序部署

问题描述:

有人能告诉我使用SQL Server数据库部署C#应用程序的准确方法吗?我想在客户端的机器上运行我的应用程序,它在我的机器上运行,但在客户端的机器上显示错误。我可以使用clickonce技术在客户端的机器上安装SQL Server 2008。一切都很好,直到我尝试在我的应用程序中访问数据库。我对部署的了解很少,因为我是第一次这样做。我知道需要附加.mdf文件。请告诉我确切的部署步骤,以便我能够在客户端的机器上运行我的应用程序。如何在客户端机器上部署数据库??。我可以在客户端机器上更改安装路径吗?默认情况下它安装在C:/ Users / Admin / Appdata / Roaming / .......路径



我尝试过:



我创建了一个包含数据库的安装文件。当我在客户机上部署我的应用程序时,它无法访问数据库抛出错误

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确以及SQL Server是否正确配置为允许远程连接

我应该写什么连接字符串来访问客户机上的数据库?或者你可以导航我一步一步的Windows部署过程

can anyone tell me the accurate way of deployment my C# application with a SQL Server database? I want to run my application on client's machine, it is running on my machine but showing error on client's machine. I am able to install SQL Server 2008 on client's machine using clickonce technique. Everything is fine until I try to access database in my application. I know little about deployment as I am doing it for the first time. I know there is a need to attach .mdf file . Please tell me the exact steps of deployment so that I am able to run my application on client's machine.How should I deploy database on client machine ??.Can I change installation path on client machine?? By default it gets installed on C:/Users/Admin/Appdata/Roaming/....... path

What I have tried:

I have created a setup file with database included in it.When I deploy my application on client machine it is unable to access the database throwing error
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections"
What connection string should I write to access the database on client machine ??Or you can navigate me to step by step process of windows deployment

0)您是在安装Sql Server 2008还是Sql Server Express 2008?



1)您使用的是用于安装SQL Server的实际Microsoft安装程序?



2)安装SQL Server比安装SQL Server Express要多得多。



3)您必须修改代码(在应用程序中),以便它可以检测已安装的SQL Server实例,并相应地设置连接字符串。



4)您的代码可能不应该只复制MDF文件,因为客户端可能已经安装了SQL Server,而且我不兼容使用您的MDF文件。相反,您应该使用一系列查询来导入架构,以及可能随应用程序提供的任何数据。
0) Are you installing Sql Server 2008, or Sql Server Express 2008?

1) Are you using the actual Microsoft installer to install SQL Server?

2) Installing SQL Server is much more involved than installing SQL Server Express.

3) You have to modify your code (in your application) so that it can detect the installed SQL Server instance, and set the connection string accordingly.

4) Your code should probably NOT just copy the MDF file because the client may already have SQL Server installed, and it my be incompatible with your MDF file. Instead, you should use a series of queries to import your schema, as well as any data that might be supplied with your application.