S
shapper
Hello,
I am need to get a connection string details. I am doing as follows:
01: Dim connectionStrings As New ConnectionStringSettingsCollection
02: Dim connectionString As New ConnectionStringSettings
03: connectionString = connectionStrings.Item("MyConn")
04: Console.WriteLine(" Connection String: ",
connectionString.ConnectionString) *** ERROR ***
05: Console.WriteLine(" Name: ", connectionString.Name)
06: Console.WriteLine(" Provider Name: ",
connectionString.ProviderName)
I get my first error on line 04
System.NullReferenceException: Object reference not set to an
instance of an object.
To check my connection string I did the following:
Dim otherConnectionString As String =
ConfigurationManager.ConnectionStrings("MyConn").ConnectionString
Response.Write(otherConnectionString)
And I get:
Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and
Settings\User\My Documents\Visual Studio
2005\WebSites\MySite\App_Data\MySite.mdb; User Id=; Password=;
Which proves I have the connection string with name MyConn in my
web.config.
Could someone tell me what am I doing wrong?
I tried everything I could think off.
Thanks,
Miguel
I am need to get a connection string details. I am doing as follows:
01: Dim connectionStrings As New ConnectionStringSettingsCollection
02: Dim connectionString As New ConnectionStringSettings
03: connectionString = connectionStrings.Item("MyConn")
04: Console.WriteLine(" Connection String: ",
connectionString.ConnectionString) *** ERROR ***
05: Console.WriteLine(" Name: ", connectionString.Name)
06: Console.WriteLine(" Provider Name: ",
connectionString.ProviderName)
I get my first error on line 04
System.NullReferenceException: Object reference not set to an
instance of an object.
To check my connection string I did the following:
Dim otherConnectionString As String =
ConfigurationManager.ConnectionStrings("MyConn").ConnectionString
Response.Write(otherConnectionString)
And I get:
Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and
Settings\User\My Documents\Visual Studio
2005\WebSites\MySite\App_Data\MySite.mdb; User Id=; Password=;
Which proves I have the connection string with name MyConn in my
web.config.
Could someone tell me what am I doing wrong?
I tried everything I could think off.
Thanks,
Miguel