The ConnectionString property has not been initialized. RRS feed

  • Question

  • i m new at asp.net ...i have error like page which is,

    Server Error in '/WebSite1' Application.

    The ConnectionString property has not been initialized.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.

    Source Error:

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

      <%@ Page Language="C#" Debug="true" %>


    2) Add the following section to the configuration file of your application:

           <compilation debug="true"/>

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

    Stack Trace:

    [InvalidOperationException: The ConnectionString property has not been initialized.]
    System.Data.OleDb.OleDbConnection.PermissionDemand() +1132583
    System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection) +22
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
    System.Data.OleDb.OleDbConnection.Open() +37
    signup.Button2_Click(Object sender, EventArgs e) +1532
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

    Version Information:  Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

    Friday, August 28, 2009 4:21 PM


  • Hello,Ravi
    please make sure you have set the ConnectionString property of OleDbConnection instance.

    Here is an example on MSDN:

    class Class1
        static void Main()
            string x = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=AdventureWorks;"
                + "Integrated Security=SSPI";

        static void OpenConnection(string connectionString)
            using (OleDbConnection connection = new OleDbConnection(connectionString))
                    Console.WriteLine("ServerVersion: {0} \nDataSource: {1}",
                        connection.ServerVersion, connection.DataSource);
                catch (Exception ex)
                // The connection is automatically closed when the
                // code exits the using block.

    Wenn ich dich hab’,gibt es nichts, was unerträglich ist.坚持不懈!http://hi.baidu.com/1987raymond
    • Marked as answer by Yichun_Feng Thursday, September 3, 2009 2:48 AM
    Monday, August 31, 2009 3:08 AM