SQL Server Settings save

Hi,

I was wondering if someone could give me some guidance on saving your SQL server information so that next time you open your application you don't need to enter all the info again i.e. ServerName, Database, Username etc.

I do want the user to set this up, so I don't want to hard code it in the application.

I would really appreciate the help.

[634 byte] By [Lawrence007] at [2007-12-28]
# 1

In my experience the usual way of doing this is to use the application configuration file to store the information in. Some folks prefer to use the registry though.

I find the simplest way is to add the value to your settings file and read it in your code through My.Settings.XXX where XXX is the settings name you assigned (eg ConnStr). You can configure the settings values to persist automatically when the application shuts down if you want to.

There are of course other alternatives (eg you need a more secure solution, to support an unknown number of strings etc) but the config file approach seems to fit most of the time.

Hope this helps.

Richard

DickDonny at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2

Thanks Richard,

No I know where to start.

Lawrence007 at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3

Lawrence 007,

You can also write the coeectionString in your seetings file like this:

dim connectionString as String="Initial Catalog=DatabaseName; Data Source=(local);Integrated Security=SSPI;"

"server=(local);database=DatabaseName;uid=sa;pwd=***;"

"Provider=SQLOLEDB; Initial Catalog=DatabaseName; Data Source=(local);Integrated Security=SSPI;"

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...