Link to home
Start Free TrialLog in
Avatar of gobofo
gobofo

asked on

Connection string error: Requested value 'ConnectionStrings' was not found

I'm using ASP.NET 2.0 with VB and I added a table adapter to my dataset that has a bunch of other adapters.  no problem here.  The adapter needed a new conn string so I added one - with a period in the string name ("DataWarehouse.ETL").  Once I did that my website won't build and I get the following error:

"Failed to load dataset because of the following error: Requested value 'ConnectionStrings' was not found."

Everything I've read about the error says that removing the "." from the string and building the site will work, but my project is still hosed.  I've restarted VS, restarted the dev box and it's still not working - help?

ASKER CERTIFIED SOLUTION
Avatar of jinn_hnnl
jinn_hnnl
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gobofo
gobofo

ASKER

figured it out - I missed one reference to the incorrect conn string (the one with the ".").  I just had to make sure all references were updated in both the webconfig AND the dataset code.
That's true,

Well as I feel guilty for getting this mark, I just wanna mention something that you might already know.

When we dealing with stuff like connection string which connected to database and we can have different developing database server, testing server. It's best to separate them and not hard coded them in your code behind

In another word, store conn in webconfig and refer to the application setting key using Configuration class:
Instead of
conn.ConnectionString = "data source=.\SQLEXPRESS;Integrated Security=SSPI;....";

refer to the webconfig
conn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["myDB"]

in web config
<connectionStrings>
        <add name="myDB"
            connectionString="Data Source=.\SQLEXPRESS; .... />
    </connectionStrings>

when the database path changed, you only have to change in web.config and dont have to recompile the code

>.<

well,

Thanks for the credit though

JINN
I figuered it out myself. When using the Table Adapter Tool you are asked at one point to create a connection string. When you go to name the connection string if you have a a "." in the name, such as before the mdf extension of the database, like I did, it will throw the error every time. Solution: Be careful to name your connection string without any "." when the tool asks for a name. It appears to be working now.