8 Replies - 1670 Views - Last Post: 24 April 2013 - 12:43 PM Rate Topic: -----

#1 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

The ConnectionString property has not been initialized

Posted 23 April 2013 - 02:17 AM

:helpsmilie:

I delete old database and add one new but there is a problem when I try to connect to database

I tried to see if there problem from database because I'm shore that codes are right since it was working with old database

so I tried with store producer and executes ok but nothing insert in table !! so I dont know if the problem form database or from ConnetionString in config ?

Is This A Good Question/Topic? 0
  • +

Replies To: The ConnectionString property has not been initialized

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 02:35 AM

What are the differences between the databases? If they were identical, there wouldn't be a problem.

Did you change the database or schema names? The table structure? The user access? The server version? Anything else?

Are you getting any errors? If not, have you tried stepping through the program with a debugger to see exactly what is happening during the execution?

Without details like that, it's hard for us to offer any real advice. What you've told us is very little to go on.
Was This Post Helpful? 0
  • +
  • -

#3 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 03:04 AM

 SqlConnection con = new SqlConnection();
            SqlCommand cmd = new SqlCommand("db_vid", con);
            cmd.CommandType = CommandType.StoredProcedure;
            con.ConnectionString = ConfigurationManager.ConnectionStrings[1].ToString();
con.Open();



and here config

  <connectionStrings>
    
    <add name="OVSSKEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\DataBase.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
     providerName="System.Data.EntityClient" />
    <add name="ConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DataBase.mdf;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

Was This Post Helpful? 0
  • +
  • -

#4 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 03:10 AM

View PostAtli, on 23 April 2013 - 02:35 AM, said:

What are the differences between the databases? If they were identical, there wouldn't be a problem.

Did you change the database or schema names? The table structure? The user access? The server version? Anything else?

Are you getting any errors? If not, have you tried stepping through the program with a debugger to see exactly what is happening during the execution?

Without details like that, it's hard for us to offer any real advice. What you've told us is very little to go on.


new database with new name and there are no error with that only when I try to connect database to store data or read from this error

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#5 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,476
  • Joined: 07-April 08

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 07:50 AM

Are you sure that the mdf files are the same?

Also your connection string looks a little off. Try matching this one (From connectionstrings.com) and see if it works:
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;
Trusted_Connection=Yes;


This post has been edited by rgfirefly24: 23 April 2013 - 07:54 AM

Was This Post Helpful? 0
  • +
  • -

#6 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 10:52 AM

View Postrgfirefly24, on 23 April 2013 - 07:50 AM, said:

Are you sure that the mdf files are the same?

Also your connection string looks a little off. Try matching this one (From connectionstrings.com) and see if it works:
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;
Trusted_Connection=Yes;





the problem is my exprent is zero this my first time working with asp.net and sql I'm working on my graduate project :sweatdrop:

and I'm not sure if the mdf filed are the same cuz I didnt understand >.<



<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    
    <add name="OVSSKEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\DataBase.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
     providerName="System.Data.EntityClient" />
    <add name="ConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DataBase.mdf;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
      <buildProviders>
        <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
      </buildProviders>
    </compilation>
    <httpRuntime maxRequestLength="512000" />
  </system.web>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>



please help me I have to finish my project this week :crazy:
Was This Post Helpful? 0
  • +
  • -

#7 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 12:43 PM

could be this the main problem !!

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,476
  • Joined: 07-April 08

Re: The ConnectionString property has not been initialized

Posted 23 April 2013 - 03:25 PM

have you even tried to change your connection string to match the one I posted? Also the error message you just posted is pretty obvious in that your config file (at line 318) has a section that is already defined.
Was This Post Helpful? 0
  • +
  • -

#9 dq1406  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 18-March 13

Re: The ConnectionString property has not been initialized

Posted 24 April 2013 - 12:43 PM

I tried to use the code you give me but didnt work

<add name="OVSSKEntities" connectionString="Server=.\SQLExpress;AttachDbFilename=|DataDirectory|DataBase.mdf;Database=dbname;Trusted_Connection=Yes;" />
   


stile the same problem

and for IIS7 thanks I fix it by delete what it is says in the error
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1