Solved

{System.Configuration.ConfigurationErrorsException: easy question.

Posted on 2008-06-10
7
1,535 Views
Last Modified: 2013-12-17
The requested database Data Source=SCWB2.WPG.CWB.CA;Persist Security Info=True;User ID=mxcupryk;Password=xxxx;Unicode=True is not defined in configuration.


 try
                {
                    // Create the Database object, using the default database service. The
                    // default database service is determined through configuration.

                    Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.ConnectionStrings["InitialPrices.Properties.Settings.ConnectionString"].ConnectionString);  // Crashes here.


                    // Create the DbCommand object
                    DbCommand dbCommand = db.GetStoredProcCommand("insert_price_list_hdr");
                    dbCommand.CommandTimeout = 180;
                   
                    db.AddInParameter(dbCommand, "@p_price_list_hdr_id", DbType.String, txtCropYear.Text + txtListNo.Text);
                    db.AddInParameter(dbCommand, "@p_wht_tough_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_wht_damp_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_wht_stone_disc_amt", DbType.Decimal, 0.0);

                    db.AddInParameter(dbCommand, "@p_durum_tough_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_durum_damp_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_durum_stone_disc_amt", DbType.Decimal, 0.0);

                    db.AddInParameter(dbCommand, "@p_bly_tough_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_bly_damp_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_bly_stone_disc_amt", DbType.Decimal, 0.0);

                    db.AddInParameter(dbCommand, "@p_desigtd_bly_tough_disc_amt", DbType.Decimal, 0.0);
                    db.AddInParameter(dbCommand, "@p_desigtd_bly_damp_disc_amt", DbType.Decimal, 0.0);

                    db.AddInParameter(dbCommand, "@p_price_list_status_type_name", DbType.String, 0.0);
                    db.AddInParameter(dbCommand, "@p_load_dtm", DbType.DateTime, System.DateTime.Now);
                    db.AddInParameter(dbCommand, "@p_user_name", DbType.String, "Mathieu");


                    db.AddInParameter(dbCommand, "@p_wht_indr_flag", DbType.String, "1");
                    db.AddInParameter(dbCommand, "@p_durum_indr_flag", DbType.String, "1");
                    db.AddInParameter(dbCommand, "@p_bly_indr_flag", DbType.String, "1");
                    db.AddInParameter(dbCommand, "@p_desigtd_bly_indr_flag", DbType.String, "1");

                    db.AddInParameter(dbCommand, "@p_load_type_name", DbType.String, "Adjustment");
                    db.AddInParameter(dbCommand, "@p_pool_part_code", DbType.String, "1");
                    db.AddInParameter(dbCommand, "@p_sct_price_list_name", DbType.String, "1");
                    db.AddInParameter(dbCommand, "@p_row_cnt_qty", DbType.Decimal, "1");
                    db.AddInParameter(dbCommand, "@p_price_sum_amt", DbType.Decimal, 0);
                    db.ExecuteNonQuery(dbCommand);
                   
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }


The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource 'file:///C:/Documents and Settings/mxcupryk/Local Setti...

   at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.ValidateConnectionStringSettings(String name, Con...


{"The requested database Data Source=SCWB2.WPG.CWB.CA;Persist Security Info=True;User ID=mxcupryk;Password=abcd;Unicode=True is not defined in configuration."}

The requested database Data Source=SCWB2.WPG.CWB.CA;Persist Security Info=True;User ID=mxcupryk;Password=abcd;Unicode=True is not defined in configuration.

{Name = "DatabaseConfigurationView" FullName = "Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView"}

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="InitialPrices.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <connectionStrings>
        <add name="InitialPrices.Properties.Settings.ConnectionString"
            connectionString="Data Source=SCWB2.WPG.CWB.CA;Persist Security Info=True;User ID=mxcupryk;Password=xxxx;Unicode=True"
            providerName="System.Data.OracleClient" />
    </connectionStrings>
    <applicationSettings>
        <InitialPrices.Properties.Settings>
            <setting name="InitialPrices_InitialPriceReportingWS_InitialPriceReportingService"
                serializeAs="String">
                <value>http://localhost:50300/InitialPriceReportingService/InitialPriceReportingService.asmx</value>
            </setting>
        </InitialPrices.Properties.Settings>
    </applicationSettings>
</configuration>

Open in new window

0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 19

Expert Comment

by:elimesika
ID: 21754917
HI

You have mistaken name , use code below :

The name used in the configuration file is : "InitialPrices.Properties.Settings"
You had : "InitialPrices.Properties.Settings.ConnectionString"
  Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.ConnectionStrings["InitialPrices.Properties.Settings"].ConnectionString); 

Open in new window

0
 

Author Comment

by:mathieu_cupryk
ID: 21754954
{"Object reference not set to an instance of an object."}
0
 
LVL 19

Expert Comment

by:elimesika
ID: 21754999
HI

I want to check if there is a problem with the dots in the name , can you change the name to simply "A" in the config file and also the code to:
Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.ConnectionStrings["A"].ConnectionString); 

Open in new window

0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 19

Expert Comment

by:elimesika
ID: 21755009
config file section :
 <connectionStrings>
        <add name="A"
            connectionString="Data Source=SCWB2.WPG.CWB.CA;Persist Security Info=True;User ID=mxcupryk;Password=xxxx;Unicode=True"
            providerName="System.Data.OracleClient" />
    </connectionStrings>

Open in new window

0
 
LVL 14

Accepted Solution

by:
ajitha75 earned 500 total points
ID: 21755408
Try

DatabaseFactory.CreateDatabase("InitialPrices.Properties.Settings.ConnectionString")

You have to pass the name of the connection string and not the connection string itself.
0
 

Author Comment

by:mathieu_cupryk
ID: 21756167
anyone else?
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 21756614
Also, your connection string is missing initial catalog attribute, which will define the database that it has to point to
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question