469,347 Members | 5,898 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,347 developers. It's quick & easy.

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
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <!-- 
  3.     Note: As an alternative to hand editing this file you can use the 
  4.     web admin tool to configure settings for your application. Use
  5.     the Website->Asp.Net Configuration option in Visual Studio.
  6.     A full list of settings and comments can be found in 
  7.     machine.config.comments usually located in 
  8.     \Windows\Microsoft.Net\Framework\v2.x\Config 
  9. -->
  10. <configuration>
  11.   <appSettings>
  12.     <add key="con" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://vijayawadanalanda.org/dbnalanda/nalandavja.mdb;Persist Security Info=True"/>
  13.     <add key="adminUsername" value="admin"/>
  14.     <add key="adminPassword" value="123456"/>
  15.   </appSettings>
  16.     <connectionStrings/>
  17.     <system.web>
  18.         <!-- 
  19.             Set compilation debug="true" to insert debugging 
  20.             symbols into the compiled page. Because this 
  21.             affects performance, set this value to true only 
  22.             during development.
  23.  
  24.             Visual Basic options:
  25.             Set strict="true" to disallow all data type conversions 
  26.             where data loss can occur. 
  27.             Set explicit="true" to force declaration of all variables.
  28.         -->
  29.         <compilation debug="true" strict="false" explicit="true"/>
  30.         <pages>
  31.             <namespaces>
  32.                 <clear/>
  33.                 <add namespace="System"/>
  34.                 <add namespace="System.Collections"/>
  35.                 <add namespace="System.Collections.Specialized"/>
  36.                 <add namespace="System.Configuration"/>
  37.                 <add namespace="System.Text"/>
  38.                 <add namespace="System.Text.RegularExpressions"/>
  39.                 <add namespace="System.Web"/>
  40.                 <add namespace="System.Web.Caching"/>
  41.                 <add namespace="System.Web.SessionState"/>
  42.                 <add namespace="System.Web.Security"/>
  43.                 <add namespace="System.Web.Profile"/>
  44.                 <add namespace="System.Web.UI"/>
  45.                 <add namespace="System.Web.UI.WebControls"/>
  46.                 <add namespace="System.Web.UI.WebControls.WebParts"/>
  47.                 <add namespace="System.Web.UI.HtmlControls"/>
  48.             </namespaces>
  49.         </pages>
  50.         <!--
  51.             The <authentication> section enables configuration 
  52.             of the security authentication mode used by 
  53.             ASP.NET to identify an incoming user. 
  54.         -->
  55.         <authentication mode="None"/>
  56.         <!--
  57.             The <customErrors> section enables configuration 
  58.             of what to do if/when an unhandled error occurs 
  59.             during the execution of a request. Specifically, 
  60.             it enables developers to configure html error pages 
  61.             to be displayed in place of a error stack trace.
  62.  
  63.         <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  64.             <error statusCode="403" redirect="NoAccess.htm" />
  65.             <error statusCode="404" redirect="FileNotFound.htm" />
  66.         </customErrors>
  67.         -->
  68.         <customErrors mode="Off" defaultRedirect="errorpage.htm">
  69.             <!--<error statusCode="403" redirect="NoAccess.htm" />
  70.             <error statusCode="404" redirect="FileNotFound.htm" />-->
  71.         </customErrors>
  72.     </system.web>
  73. </configuration>
---------------------------------------------------------------------------------------

feedback.aspx.vb code is

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Data.OleDb
  3. Imports System.Configuration
  4.  
  5.  
  6. Partial Class feedback
  7.     Inherits System.Web.UI.Page
  8.  
  9.     Dim con As New OleDbConnection(ConfigurationManager.AppSettings("con"))
  10.     Dim cmd As OleDbCommand
  11.     Dim dr As OleDbDataReader
  12.  
  13.     Protected Sub BtnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
  14.         TxtName.Text = ""
  15.         TxtEmail.Text = ""
  16.         RbtRank.SelectedIndex = -1
  17.         TxtComments.Text = ""
  18.         LblResult.Text = ""
  19.  
  20.  
  21.     End Sub
  22.  
  23.     Protected Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click
  24.         Try
  25.             Dim str As String = ""
  26.             str = "INSERT INTO FEEDBACK_INFO(FB_NAME,FB_EMAIL,FB_RANK,FB_COMMENTS) VALUES('" & TxtName.Text & "','" & TxtEmail.Text & "','" & RbtRank.SelectedValue & "','" & TxtComments.Text & "')"
  27.             cmd = New OleDbCommand(str, con)
  28.             cmd.Connection.Open()
  29.             cmd.ExecuteNonQuery()
  30.             cmd.Connection.Close()
  31.             LblResult.Text = "Thanks for your feedback"
  32.  
  33.         Catch ex As Exception
  34.             LblResult.Text = ex.Message()
  35.         End Try
  36.     End Sub
  37.  
  38.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  39.  
  40.     End Sub
  41. End Class
-----------------------------------------------------------------------

Thankyou for any help
Jun 4 '09 #1
6 2938
dorandoran
145 100+
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\client\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.

http://www.connectionstrings.com/access
Jun 4 '09 #2
Frinavale
9,735 Expert Mod 8TB
@praveenb000
No you aren't.

@praveenb000
See the <connectionStrings /> 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.
Jun 4 '09 #3
Thanks for your reply. i find the solution.

Thank you very much Lol (dorandoran,Frinavale)
Jun 4 '09 #4
dorandoran
145 100+
praveen , please post your solution so other can follow if they are having similar issue(s). thanks.
oh, glad you found the workaround.
Jun 4 '09 #5
ya, this is what i did to solve
Expand|Select|Wrap|Line Numbers
  1.  <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

Expand|Select|Wrap|Line Numbers
  1. <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.
Jun 6 '09 #6
dorandoran
145 100+
Glad you got it to work.
Jun 6 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Tony Lee | last post: by
5 posts views Thread by Nathan Given | last post: by
reply views Thread by justSteve | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.