SQL连接+ INI文件 [英] SQL Connection + INI File

查看:236
本文介绍了SQL连接+ INI文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

如何使用sql server和Ini文件连接表单?

因此,当您加载表单时,请阅读ini文件的设置

Hello
How to connect a form with sql server and Ini file?
So when you load the form read the settings for ini file

推荐答案

首先,不要使用INI文件 - 它们已经过时了!现在有更简单的方法,特别是在.NET应用程序中。



在Visual Studio中打开项目,然后查看Solution Explorer窗格。打开项目bach,双击Settings.settings

在显示的页面中,添加一个新设置:

First off, don't use INI files - they are seriously outdated! There are much simpler ways to do it now, particularly in .NET applications.

Open your project in Visual Studio, and look at the Solution Explorer pane. Open teh project bach, and double click on "Settings.settings"
In the page that appears, add a new setting:
Name:  ConnectionString
Type:  String
Scope: User
Value: --Set to your default connection string--



保存文件(CTRL + S会这样做)并关闭页面。

现在,在你的代码中你可以说:


Save the file (CTRL+S will do it) and close the page.
Now, in your code you can just say:

string strConnect = Properties.Settings.Default.ConnectionString;

,系统将为您排序。

如果你想要改变它,只需要反转过程:

and the system will sort it all out for you.
If you want to change it, just reverse the process:

Properties.Settings.Default.ConnectionString = strConnect;
Properties.Settings.Default.Save();


这篇关于SQL连接+ INI文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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