To use Data acess application block with web application VS 2008

Reply

Join Date: Dec 2008
Posts: 10
Reputation: skumar.snl is an unknown quantity at this point 
Solved Threads: 0
skumar.snl skumar.snl is offline Offline
Newbie Poster

To use Data acess application block with web application VS 2008

 
0
  #1
Dec 18th, 2008
At run time I am getting error requested database does not exist in configuration see at Line 19
string con = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ConnectionString;
  1. Line 19: Database db = DatabaseFactory.CreateDatabase(con);
  2. Line 20: string sqlcmd = "select * from Movies where MovieID<500";
  3. Line 21: DbCommand dbcommand = db.GetSqlStringCommand(sqlcmd);

In my webconfig i have given required Code in web config
  1. <configSections><section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/></configSections>
  2.  
  3. <connectionStrings><add name="AdventureWorksDB" providerName="System.Data.SqlClient" connectionString="server=localhost;database=AdventureWorks;UID=user;PWD=word;"/><connectionStrings>
  4. <dataConfiguration defaultDatabase="AdventureWorksDB"/>

i have even added required DLL....
i also configured the EnterPrise Library

i defined there required connection string

followed steps in given link http://www.datadirect.com/developer/...t-net-daab.pdf.

but of no result ..

can some one tell me
Last edited by peter_budo; Dec 18th, 2008 at 3:29 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: vasioky is an unknown quantity at this point 
Solved Threads: 1
vasioky vasioky is offline Offline
Newbie Poster

Re: To use Data acess application block with web application VS 2008

 
0
  #2
Dec 18th, 2008
your problem is here :
string con = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ConnectionString;
you have no connection string with name "cn" your connection string is called AdventureWorksDB this mean you have to write :

System.Web.Configuration.WebConfigurationManager.ConnectionStrings["AdventureWorksDB "].ConnectionString;
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 10
Reputation: skumar.snl is an unknown quantity at this point 
Solved Threads: 0
skumar.snl skumar.snl is offline Offline
Newbie Poster

Re: To use Data acess application block with web application VS 2008

 
0
  #3
Dec 18th, 2008
System.Web.Configuration.WebConfigurationManager.ConnectionStrings["AdventureWorksDB "].ConnectionString;

my connection string is same name as in webconfig file..
i checked still getting same error database in not defined in config
Is there any default setting for connection? other then webconfig
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: vasioky is an unknown quantity at this point 
Solved Threads: 1
vasioky vasioky is offline Offline
Newbie Poster

Re: To use Data acess application block with web application VS 2008

 
0
  #4
Dec 18th, 2008
ok the second problem can be also in your web.config declaration. you have to different database but I'm not sure because I never used dataConfiguration tag. Hope this will solve your problem.
<connectionStrings><add name="AdventureWorksDB" providerName="System.Data.SqlClient" connectionString="server=localhost;database=AdventureWorks;UID=user;PWD=word;"/><connectionStrings> 
<dataConfiguration defaultDatabase="AdventureWorksDB"/>
Last edited by peter_budo; Dec 18th, 2008 at 3:30 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum


Views: 973 | Replies: 3
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC