当我安装我的窗口表单应用程序另一台机器数据库未连接 [英] When I Install My Window Form Application Another Machine Database Not Connected

查看:60
本文介绍了当我安装我的窗口表单应用程序另一台机器数据库未连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生PLZ帮助我安装我的窗口表格应用程序时另一台机器数据库未连接



错误: -

< pre lang =asm> Unhandle在您的应用程序中发生异常。

建立与sql server的连接时发生与网络相关的特定于实例的错误。服务器找到 无障碍。验证实例名称是否正确 sql server配置为允许远程连接(提供:SQL网络接口,错误:-26 ERROR locatings server / intance指定)

解决方案

您可能已经对连接字符串进行了硬编码 - 将其作为源代码中的字符串包含在内 - 并且你需要做的第一件事就是改变它以使用一些描述的配置文件。



最简单的方法是使用Settings.Settings文件:

1)在解决方案资源管理器中打开项目属性,然后双击Settings.settings

2)在结果网格中,将名称更改为MySetting,并设置价值违约价值。将类型和范围分别保留为字符串和用户。

3)保存并关闭设置窗口。

4)阅读设置:

 string s = Properties.Settings.Default.MySetting; 

5)写下你的设置:

 Properties.Settings.Default.MySetting =我的新设定值; 
Properties.Settings.Default.Save();





然后您需要提供一种更改配置文件的机制,以便您可以为其设置适当的连接字符串新环境。我们不能说的是:大多数开发SQL服务器实例倾向于使用Windows授权进行登录,而生产者通常使用用户名和密码保护 - 您必须从数据库管理员中找出字符串应该是什么。


首先检查您正在使用的数据库。如果它是SQL Server,那么检查数据库连接字符串。



最好的方法是使用inbuild数据库,它不会产生任何重新更改连接字符串的问题。

sir plz help me when i install my window form application another machine database not connected

ERROR:-

Unhandle Exception has occurred in your application.

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 connection(provide: SQL network interfaces, error:-26 ERROR locatings server/intance specified)

解决方案

The chances are that you have hardcoded your connection string - included it as a string in your source code - and that the first thing you need to do is change that to use a configuration file of some description.

The simplest is to use the Settings.Settings file:
1) Open your projects Properties in the solution explorer, and double click on "Settings.settings"
2) In the resulting grid, change the Name to "MySetting", and set the Value to "Defaulted value". Leave Type and Scope as "string" and "User" respectively.
3) Save and close the settings window.
4) To read your setting:

string s = Properties.Settings.Default.MySetting;

5) To write your setting:

Properties.Settings.Default.MySetting = "My new setting value";
Properties.Settings.Default.Save();



Then you need to provide a mechanism for changing the configuration file so that you can set the appropriate connection string for the new environment. What that will be we can't say: most development SQL server instances tend to use Windows authorisation for log in, while production ones are generally username and password protected - you will have to find out from the db admin what the string should be.


First of all check which database you are using. If it is SQL Server then check the database connection string.

The best way is to use the inbuild database which will not create any issue regrading the changing the connection string.


这篇关于当我安装我的窗口表单应用程序另一台机器数据库未连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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