Connection to SQL2005 using VB 2005 Beta2
Hi !
I was using these commands with VB2005 Beta1 to load my main form:
Dim
settingsAs Configuration.SettingsProviderCollection = System.Configuration.ConfigurationSettings.ConnectionString
Dim
settingAs SqlConnectionStringBuilder = settings.Item("VBXMP3.MySettings.Connection")Now I reInstalled VB2005 Beta2 and I cannot compile my project.
The error isConnectionString is not a member of ConfigurationSettings.
Does anyone have an idea to workaround this issue ?
Is there another way to make the same ?
Thanx a lot for your answers !
Max
[861 byte] By [
TheMax] at [2008-2-2]
TheMax wrote: |
Hi ! I was using these commands with VB2005 Beta1 to load my main form: Dim settings As Configuration.SettingsProviderCollection = System.Configuration.ConfigurationSettings.ConnectionString Dim setting As SqlConnectionStringBuilder = settings.Item("VBXMP3.MySettings.Connection")Now I reInstalled VB2005 Beta2 and I cannot compile my project. The error is ConnectionString is not a member of ConfigurationSettings. Does anyone have an idea to workaround this issue ? Is there another way to make the same ? Thanx a lot for your answers ! Max |
|
Max,
You can have more than one connection string in a config file. You will want to access the ConnectionStrings property, which returns a ConnectionStringSettingsCollection, from which you can access your connection string.
Hope this helps.
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
Hi,
Nick has a good suggestion.
In addition you can use the Project Designer to make working with connection strings and settings easier. Here's a little walk thru:
1) double click on the My Project node in your project. This opens the Project Designer.
2) Click on the Settings tab on the right-hand-side
3) Add a new setting "MyConnection", and set the type to Connection String
4) Save and close the Project Designer pane
5) in your code, access the setting value by typing:
| | Dim connString as String = My.Settings.MyConnection |
Each setting that you add will show up dynamically in the My.Settings. namespace.
Best,
Paul