configurationmanager.connection string giving System.NullReferenceException was unhan
Dear Sir,
I am in great trouble, I have a project on visual studio 2008 and I getting connectionstring using ConfigurationManager.ConnectionStrings("connestionstring").ConnectionString. this project have a app.config file which contain
/code
<connectionStrings>
<add name="RMINVENTORY" connectionString="Server=localhist;Initial Catalog=Northwind;Integrated Security=SSPI" />
</connectionStrings
I get the connection using str variable like this
dim str as string
str=ConfigurationManager.ConnectionStrings("RMINVENTORY").ConnectionString
code/
In visual 2008 it works perfectly, but in 2010 it giving the error like this
"System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=Inventory.Metadata"
Please help where is the problem
Thanking You
Debasis Bag
Re: configurationmanager.connection string giving System.NullReferenceException was u
Because it's not a string. It is a ConnectionString(). Press F1 for HELP! .ToString will convert it, but it won't work.
Re: configurationmanager.connection string giving System.NullReferenceException was u
Where does the code blow up at? The message does not seem to point to the code you have shown so I have no idea where yuour problem may be. Run it in debug mode and see what line is executing when the error is generated.
Re: configurationmanager.connection string giving System.NullReferenceException was u
I would say that the web.config file doesn't contain your connection string (check for spelling errors)
Re: configurationmanager.connection string giving System.NullReferenceException was u
Quote:
Originally Posted by
Debasis Bag
<add name="RMINVENTORY" connectionString="Server=localhist;Initial Catalog=Northwind;Integrated Security=SSPI" />
Should that not be Localhost...