MS Access database connectivity problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praveenb000
    New Member
    • Aug 2008
    • 21

    MS Access database connectivity problem

    we hosted a website http://vijayawadanalanda.org
    developed using asp.net and back end MS Accees database.

    There is some database connectivity problem occurring when saving the information in page
    url : http://vijayawadanalanda.org/feedback.aspx

    getting error: Not a valid file name.

    Please provide me solution to rectify this problem.

    i used web.config for conndction string setting

    web.config file code is
    Code:
    <?xml version="1.0"?>
    <!-- 
        Note: As an alternative to hand editing this file you can use the 
        web admin tool to configure settings for your application. Use
        the Website->Asp.Net Configuration option in Visual Studio.
        A full list of settings and comments can be found in 
        machine.config.comments usually located in 
        \Windows\Microsoft.Net\Framework\v2.x\Config 
    -->
    <configuration>
      <appSettings>
        <add key="con" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://vijayawadanalanda.org/dbnalanda/nalandavja.mdb;Persist Security Info=True"/>
        <add key="adminUsername" value="admin"/>
        <add key="adminPassword" value="123456"/>
      </appSettings>
    	<connectionStrings/>
    	<system.web>
    		<!-- 
                Set compilation debug="true" to insert debugging 
                symbols into the compiled page. Because this 
                affects performance, set this value to true only 
                during development.
    
                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"/>
    		<pages>
    			<namespaces>
    				<clear/>
    				<add namespace="System"/>
    				<add namespace="System.Collections"/>
    				<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>
    		<!--
                The <authentication> section enables configuration 
                of the security authentication mode used by 
                ASP.NET to identify an incoming user. 
            -->
    		<authentication mode="None"/>
    		<!--
                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>
            -->
    		<customErrors mode="Off" defaultRedirect="errorpage.htm">
    			<!--<error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />-->
    		</customErrors>
    	</system.web>
    </configuration>
    ---------------------------------------------------------------------------------------

    feedback.aspx.v b code is

    Code:
    Imports System.Data
    Imports System.Data.OleDb
    Imports System.Configuration
    
    
    Partial Class feedback
        Inherits System.Web.UI.Page
    
        Dim con As New OleDbConnection(ConfigurationManager.AppSettings("con"))
        Dim cmd As OleDbCommand
        Dim dr As OleDbDataReader
    
        Protected Sub BtnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
            TxtName.Text = ""
            TxtEmail.Text = ""
            RbtRank.SelectedIndex = -1
            TxtComments.Text = ""
            LblResult.Text = ""
    
    
        End Sub
    
        Protected Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click
            Try
                Dim str As String = ""
                str = "INSERT INTO FEEDBACK_INFO(FB_NAME,FB_EMAIL,FB_RANK,FB_COMMENTS) VALUES('" & TxtName.Text & "','" & TxtEmail.Text & "','" & RbtRank.SelectedValue & "','" & TxtComments.Text & "')"
                cmd = New OleDbCommand(str, con)
                cmd.Connection.Open()
                cmd.ExecuteNonQuery()
                cmd.Connection.Close()
                LblResult.Text = "Thanks for your feedback"
    
            Catch ex As Exception
                LblResult.Text = ex.Message()
            End Try
        End Sub
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    End Class
    -----------------------------------------------------------------------

    Thankyou for any help
    Last edited by Frinavale; Jun 4 '09, 03:02 PM. Reason: Added code tags. Please post code in [code] [/code] tags.
  • dorandoran
    New Member
    • Feb 2007
    • 145

    #2
    Check out the link below. Notice that you must provide the actual path to the database. Contact your web hosting provider and find out the path. It's usually C or D drive then bunch of directories and subdirectories. For example,
    d:\web\root\cli ent\abc.com\ this would be your account folder and it set such a way that you cant go out of this directory. So this is the path you will have to provide in order for db to connect.

    Connection strings for Access. Connect using Microsoft.ACE.OLEDB.12.0, Microsoft.Jet.OLEDB.4.0, OleDbConnection, Microsoft Access accdb ODBC Driver.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by praveenb000
      i used web.config for conndction string setting
      No you aren't.

      Originally posted by praveenb000
      web.config file code is
      Code:
      <?xml version="1.0"?>
      
      <configuration>
        <appSettings>
          <add key="con" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://vijayawadanalanda.org/dbnalanda/nalandavja.mdb;Persist Security Info=True"/>
          <add key="adminUsername" value="admin"/>
          <add key="adminPassword" value="123456"/>
        </appSettings>
      	<connectionStrings/>
      See the <connectionStri ngs /> tag?
      It's an empty tag!

      Please take a look at this article on how to read connection strings from the Web.config file for more information on how you should storing and retrieving your connection string.

      Comment

      • praveenb000
        New Member
        • Aug 2008
        • 21

        #4
        Thanks for your reply. i find the solution.

        Thank you very much Lol (dorandoran,Fri navale)

        Comment

        • dorandoran
          New Member
          • Feb 2007
          • 145

          #5
          praveen , please post your solution so other can follow if they are having similar issue(s). thanks.
          oh, glad you found the workaround.

          Comment

          • praveenb000
            New Member
            • Aug 2008
            • 21

            #6
            ya, this is what i did to solve
            Code:
             <add key="con" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://vijayawadanalanda.org/dbnalanda/nalandavja.mdb;Persist Security Info=True"/>
            i placed my access database file in App_Data folder

            and changed the data source as

            Code:
            <add key="con" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|nalandavja.mdb;Persist Security Info=True"/>
            Anyway, Thanks for your team members for supporting us at any time.
            Last edited by Frinavale; Aug 17 '09, 01:10 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

            Comment

            • dorandoran
              New Member
              • Feb 2007
              • 145

              #7
              Glad you got it to work.

              Comment

              Working...