hejahv
hejahv

Reputation: 1

Reference to connectionstring in settings

This is for a Windows Application.

In a class I want to referee to my connectionstring called freighthelper which is located in the settings.settings file in my project. How do I do this?

I have tried with this without success.

_connection.ConnectionString = FreightHelper.Properties.Settings.Default.freighthelper; 

Upvotes: 0

Views: 3181

Answers (2)

GôTô
GôTô

Reputation: 8053

Why do you need to store your connection string in a settings file? It is usually put in the config file and retrieved like this: http://msdn.microsoft.com/en-us/library/ms254494%28VS.80%29.aspx

Upvotes: 2

anishMarokey
anishMarokey

Reputation: 11397

try this: _connection.ConnectionString=Settings.Default. freighthelper; to read form a setting files.

NOte: connection string better to place in App.confing

E.g:

<connectionStrings>
    <add name="Name" connectionString="Data Source=Instance Name;Integrated Security=True;MultipleActiveResultSets=True;"
      providerName="System.Data.EntityClient" />

Upvotes: 0

Related Questions