|
-
May 24th, 2011, 01:10 AM
#1
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
-
May 24th, 2011, 11:45 AM
#2
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.
-
May 29th, 2011, 07:58 PM
#3
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.
Always use [code][/code] tags when posting code.
-
May 24th, 2012, 08:43 AM
#4
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)
-
May 24th, 2012, 12:29 PM
#5
Re: configurationmanager.connection string giving System.NullReferenceException was u
 Originally Posted by Debasis Bag
<add name="RMINVENTORY" connectionString="Server=localhist;Initial Catalog=Northwind;Integrated Security=SSPI" />
Should that not be Localhost...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|