Tuesday, March 27, 2012

Error when submitting a form: The ConnectionString property has not been intialized.

Hello! I'm recieving an error when I submit a form to an Access database. I took this site over from someone else and kept their code as I'm more of a designer than a programmer. If anyone has any ideas as to how to fix it, I would really appreciate it. I'm pretty clueless when it comes to this. I've tried to figure it out on my own, but I seem to be failing. Any help would be great! Here's what I receive when I submit the form:

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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[InvalidOperationException: The ConnectionString property has not been initialized.] System.Data.OleDb.OleDbConnection.Open() +203 modern_foods.promotions_form.saveInfo(Object s, EventArgs e) +535 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292


Thank you in advance!

I do not know how you code looks like but probably you web.config does not contain ConnectionString parameter defined, check it.|||

Hi Friend,

I think You have not created created an instance of connectionstring.

'Vb.Net ConnectionDim CnAsNew System.Data.OleDb.OleDbConnection("Your Connection String")

Cn.Open()

//c# connection

System.Data.OleDb.

OleDbConnection Cn =new System.Data.OleDb.OleDbConnection("your connection string");

Cn.Open();

Let me know if u need any further clarification

|||

Thank you for replying. I seem to be having a problem with my web.config file. Here's what it is right now:

<?xml version="1.0" encoding="utf-8" ?>

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

Here's what I think it should probably look more like....the problem is, when I upload the web.config file that looks like this, my form pages don't show up. Instead, I get another error. Here's what I thought web.config should look like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="EmailServer" value="Mail2.rjsnetworks.com" />
<add key="EmailFrom" value="contact@.modernfoods.net" />
<add key="EmailTo" value="info@.modernfoods.net" />

<add key="connLive" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=My Source" />
<add key="connDebug" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=My Source" />
</appSettings>

<system.web>

<compilation
defaultLanguage="c#"
debug="true"
/>

<customErrors
mode="Off"
/>

<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="200"
/>

requestEncoding="utf-8"
responseEncoding="utf-8"
/>

</system.web>

</configuration>

Any ideas?

|||

your web.config looks almost empty ;-), you should have something like this inside:

<?xml version="1.0" encoding="iso-8859-2" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="Personal" connectionString="Data Source=servernameorIP;Initial Catalog=Database;Persist Security Info=True;User ID=user;password=pasword"/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=servernameorIP;Initial Catalog=SecurityDatabase;Persist Security Info=True;User ID=user;password=password "/>

</connectionStrings>

|||

I agree with you there. It definitely looks empty. However, I have something similar to what you're saying in that second code that I posted, and when I upload it to the server, it cause an immediate error on my forms page. Any ideas as to why it would be doing that?

|||Maybe because it is trying to store session state informations on SQL server on your local box, do you have it installed?|||Thanks for your reply. I think you maybe right, though I'm not sure how to go about fixing it. I took out the authentication mode, authorization and sessionState, and now it works fine. How can I fix this?|||I think you're right about that, thought I'm not sure how to go about fixing it. I took out the authentication mode, the authorization and the sessionState sections, and now it's working. How should I fix those sections. Do I even need those sections in the web.config file for my forms to work properly. Thanks again for your help.|||

If it works correctly now, it is mean that you do not need them for your project probably. They are used as options for projects with form authentication, SQL server session state storage and so on. But you do not have to use them all the time.

|||Thank you so much! I'm so glad we got this resolved!

No comments:

Post a Comment