关于点网中的设置文件 [英] About set file in dot net

查看:72
本文介绍了关于点网中的设置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用c#开发一个Windows应用程序,并在创建设置项目时使用此连接字符串.


Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\HM.mdf;Integrated Security=True;user instance=true

设置文件在我的PC上成功运行,但在其他PC上未找到sql server错误

I am developing one windows application in c# and using this connection string while creating set up project.


Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\HM.mdf;Integrated Security=True;user instance=true

set up file runs on my pc successfully but getting error of sql server not found on other pc

推荐答案

一些想法:

首先,您指定的连接指向本地计算机:Data Source=.\\SQLEXPRESS,因此运行应用程序的计算机还需要一个以"SQLEXPRESS"身份运行的SQLExpress服务器.这可能是造成您问题的原因. (很难说,因为有太多因素在起作用).为了形成更便于携带的连接字符串,此站点可能会有所帮助 [此处 [ ^ ].您可以根据调试和发布版本来更改配置,但是如何执行此操作取决于您的应用程序类型和.net框架版本.最后,如果您担心用户看到连接字符串,则可以对其进行加密,这确实需要一些努力.您可以在此处 [
A few of ideas:

First the connection you have specified is pointing at the local machine: Data Source=.\\SQLEXPRESS , so the machine the application runs on will also need a SQLExpress server running as "SQLEXPRESS". This could be the cause of your problem. (It is difficult to tell as so many factors come into play). To form a more portible connection string this site may be of help[^]. You should also check the mdf file is deployed on installation. This is a slightly unusual setup as databases are typically deployed to a common server rather than locally.

The second thing is that it is more usual to store your config in the app.config (or web.cofig) file, it means you can change the database connection without deploying code for one thing. Instructions for doing that can be found here[^]. You can change the config according to debug and release builds, but how you do this depends on your application type and .net framework version. Finally, if you are worried about users seeing the connection string it is possible to encrypt it, this does take a little effort. You can see the basics here[^] but the instructions given may not fit your deployment scenario (they work on a web server for example, but the key must be accessible to the account running the application). It is possible to write your own ProtectedConfiguationProvider if necessary.


另一台PC上可能未安装SQLEXPRESS.
您指定了.\ SQLEXPRESS,这表示正在使用本地计算机的SQLEXPRESS.
The other PC might not have SQLEXPRESS installed on it.
You specified .\SQLEXPRESS, which means SQLEXPRESS of the local machine is being used.


这篇关于关于点网中的设置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆