fpoyavo
asked on
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.SqlC onnection( );
sqlConnect .ConnectionString = (string)Application["Conne ctString"] ;
sqlConnect .Open();
Thank you.
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.SqlC
sqlConnect .ConnectionString = (string)Application["Conne
sqlConnect .Open();
Thank you.
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.
If you get that excaption, then surelly
sqlConnect .ConnectionString = null;
which means
(string)Application["Conne ctString"] = null;
The problem may be with your config file, or something related with that.
sqlConnect .ConnectionString = null;
which means
(string)Application["Conne
The problem may be with your config file, or something related with that.
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.