[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Connection

Hi Experts,

I have error message : (same code and web.conf are used within other pages and works fine.)

The ConnectionString property has not been initialized


Code is :

SqlConnection sqlConnect = new System.Data.SqlClient.SqlConnection();
sqlConnect .ConnectionString = (string)Application["ConnectString"];
sqlConnect .Open();

Thank you.
0
fpoyavo
Asked:
fpoyavo
1 Solution
 
Timbo87Commented:
Are you sure you're retrieving the right data? You can test it by copying and pasting the hard-coded connection string in. Obviously don't use this in the final product, but it will be OK for testing. If it works then your problem is with Application["ConnectString"] and if it doesn't then it's a problem with your connection string.
0
 
Chester_M_RagelCommented:
If you get that excaption, then surelly
 
sqlConnect .ConnectionString = null;

which means

(string)Application["ConnectString"] = null;

The problem may be with your config file, or something related with that.
0
 
123654789987Commented:
AS Chester_M_Ragel pointed out Application["ConnectString"] = null.  U can test by harcoding the connection string in the program. If it works fine, then u can be sure the problem is with the config file.

The config file should be present in the calling assembly's project output folder, this can either be \bin or \bin\Debug according to the settings
0
 
seaziumCommented:
hi fpoyavo  ..,
this article will help u to sort out ur prob  ..,
check it and me available her for ur help  ... ,,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtbstroubleshootingdataaccessinvisualstudionet.asp

--dZelters..
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now