Where to store to connecting string in WinForm Application

A

ad

We usually store the connection string of Web Applicaiton in Web.Config.
Now I want to develop WinForm Application.
Where is the better place to store the conneciton string?
 
M

Mark Monster

Hello,

Store the Connection String in de app.config. But don't forget to encrypt
the app.config or the connectionsting alone.

Yours,

Mark Monster
 
A

abc my vclass

Can u share your simple encrypt and decrypt functions as .NET's cryptro so
complex for me?
 
P

Peter Rilling

Unless he has password in the connection string, he probably does not need
to encrypt it.
 
A

ad

I have store my connection string in ap.config, like:
<configuration>
<appSettings/>
<section name="microsoft.visualstudio.testtools"
type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection,
Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<connectionStrings>
<add name="myDataBase" connectionString="Data Source=.\;Initial
Catalog=SchoolGov;Integrated Security=True" />
</connectionStrings>
</configuration>

How can I read the connectionString into my applicaton?
 
P

Patirck Ige

In Web.Config add
<add key="ConnectionString"
value="server=(local);database=YOURDATABASE;integrated security=true;" />
And in your code use:-
Public conn As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Hope that helps
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top