Solved

ASP.net code error

Posted on 2010-11-22
2
617 Views
Last Modified: 2012-05-10
I am trying to connect to an online Access database that resides in the "DataBase" folder within my wwwroot folder. The last few lines are what I added to the bottom of my Web.Config file.
I am getting an error on the second last line "The targetFramework attribute is not allowed". What does this mean? Also if my database is online is that the right path
<?xml version="1.0"?>

<configuration>



    <appSettings/>

    <connectionStrings/>

    <system.web>

        <!-- 

            Visual Basic options:

            Set strict="true" to disallow all data type conversions 

            where data loss can occur. 

            Set explicit="true" to force declaration of all variables.

        -->

        <compilation debug="true" strict="false" explicit="true">



        </compilation>

    <!--

      The <authentication> section enables configuration 

      of the security authentication mode used by 

      ASP.NET to identify an incoming user. 

    -->

    <authentication mode="Windows" />

    <!--

       The <customErrors> section enables configuration 

       of what to do if/when an unhandled error occurs 

       during the execution of a request. Specifically, 

       it enables developers to configure html error pages 

       to be displayed in place of a error stack trace.



       <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

         <error statusCode="403" redirect="NoAccess.htm" />

         <error statusCode="404" redirect="FileNotFound.htm" />

       </customErrors>

    -->

        <pages>

          <namespaces>

            <clear />

            <add namespace="System" />

            <add namespace="System.Collections" />

            <add namespace="System.Collections.Generic" />

            <add namespace="System.Collections.Specialized" />

            <add namespace="System.Configuration" />

            <add namespace="System.Text" />

            <add namespace="System.Text.RegularExpressions" />

            <add namespace="System.Web" />

            <add namespace="System.Web.Caching" />

            <add namespace="System.Web.SessionState" />

            <add namespace="System.Web.Security" />

            <add namespace="System.Web.Profile" />

            <add namespace="System.Web.UI" />

            <add namespace="System.Web.UI.WebControls" />

            <add namespace="System.Web.UI.WebControls.WebParts" />

            <add namespace="System.Web.UI.HtmlControls" />

          </namespaces>

        </pages>

    </system.web>





  <connectionStrings>

    <add name="WhatEverNameYouWant" connectionString="Microsoft.Jet.OLEDB.4.0;Data Source=\Database\Contacts.accdb;User Id=myLogin;Password=myPass;" providerName="System.Data.OleDb"/>

  </connectionStrings>

  <system.web>

    <compilation debug="true" targetFramework="4.0"/>

  </system.web>





</configuration>

Open in new window

0
Comment
Question by:murbro
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34187255
If you read your config file carefully you will see that there is already a <connectionStrings /> element at the top, you don't need to define a second one at the bottom you, simply add to the existing one.

Your path should be ok because you are specifying a path relative to the root of your site.

If you are using Visual Studio 2010 then you can get rid of the "targetFramework" attribute as you only need it when you want to target an earlier version of the framework.

Finally, your database name shows that you are using Access 2007/10, so the driver you are using needs updating. Your overall config  should look something like:
<?xml version="1.0"?>
<configuration>

    <appSettings/>
    <connectionStrings>
    <add name="WhatEverNameYouWant" connectionString="Microsoft.ACE.OLEDB.12.0;Data Source=\Database\Contacts.accdb;User Id=myLogin;Password=myPass;" providerName="System.Data.OleDb"/>
    </connectionStrings>
    <system.web>
        <!-- 
            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
        <compilation debug="true" strict="false" explicit="true">

        </compilation>
    <!--
      The <authentication> section enables configuration 
      of the security authentication mode used by 
      ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Windows" />
    <!--
       The <customErrors> section enables configuration 
       of what to do if/when an unhandled error occurs 
       during the execution of a request. Specifically, 
       it enables developers to configure html error pages 
       to be displayed in place of a error stack trace.

       <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
         <error statusCode="403" redirect="NoAccess.htm" />
         <error statusCode="404" redirect="FileNotFound.htm" />
       </customErrors>
    -->
        <pages>
          <namespaces>
            <clear />
            <add namespace="System" />
            <add namespace="System.Collections" />
            <add namespace="System.Collections.Generic" />
            <add namespace="System.Collections.Specialized" />
            <add namespace="System.Configuration" />
            <add namespace="System.Text" />
            <add namespace="System.Text.RegularExpressions" />
            <add namespace="System.Web" />
            <add namespace="System.Web.Caching" />
            <add namespace="System.Web.SessionState" />
            <add namespace="System.Web.Security" />
            <add namespace="System.Web.Profile" />
            <add namespace="System.Web.UI" />
            <add namespace="System.Web.UI.WebControls" />
            <add namespace="System.Web.UI.WebControls.WebParts" />
            <add namespace="System.Web.UI.HtmlControls" />
          </namespaces>
        </pages>
    </system.web>
</configuration>

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 34187287
Thanks very much
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now