0

I am making an application that connects to the database. Currently I am using an .ini file to connect an application to the database. I also created a program that will modify the .ini file so that the user or admin can dynamically change the connection string to the database.

Now my problem is the .ini file is readable through notepad. I also tried to encrypt the .ini file using characters but when I try to deploy my application on windows xp, the application can't be read the the .ini file. Some of the characters can't be read by notepad.

Can you give me an idea how to implement connection using external files? What I need is an external file that can't be read by users. Can only be read by my program. Only admin can modify the connection string such as username,password and directory of the database.

I am open to any idea other than using .ini files.

0

1 Answer 1

2

Use an app.config file to store settings (including connection strings) because that they are designed for! You can also encrypt connection strings in the app.config out of the box.

Here is a link to a sample of how to encrypt / use connection strings and achieve what you are looking for: http://www.codeproject.com/Tips/598863/EncryptionplusDecryptionplusConnectionplusStringpl

Note: There are plenty of resources out there once you start looking at using app.config (or web.config if it is a website).

Sign up to request clarification or add additional context in comments.

5 Comments

I just started using c# as my programming language. App.config is a new knowledge to me. i was a vb developer before so i don't know about app.config. well I'll try to research on that
@Mandz - Not a problem and that is what this site is for, helping people! Hope it can get you started and point you in the right direction!
I'm still open for other ideas that might intrigue my knowledge ^_^
I have a follow up question with app.config. Is app.config static or changeable. example if the user edited the connection string of the app.config and he exited the application. what will happen if he opens the application again? will it be changed or the the values will be in the default values again?
Depends what you mean... If the user edits the app.config (say in Notepad) and saves then the next time it runs the changes will be picked up and used. Where you don't want them to change (i.e. ConnectionString) you could encrypt to stop them tinkering. However, the whole point of app.config is that it is the configuration for your application (like the .ini file of days gone by).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.