Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello
How to connect a form with sql server and Ini file?
So when you load the form read the settings for ini file
Posted
Comments
Maciej Los 6-May-14 4:47am    
WHat have you done till now?
Where are you stuck?
Ardi Durres 6-May-14 5:13am    
VB6 + Ini file.I have made one form with 3 buttons.Test connection save connection and close form.i have observe some previous codes but i'm so confused about the code

1 solution

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--

Save the file (CTRL+S will do it) and close the page.
Now, in your code you can just say:
C#
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:
C#
Properties.Settings.Default.ConnectionString = strConnect;
Properties.Settings.Default.Save();
 
Share this answer
 
Comments
ZurdoDev 13-May-16 11:27am    
Great description. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900