Jump to content

Writing to Access Tables not working on server


Recommended Posts

Hi,I have been using SAMs Teach Yourself ASP.NET 2.0 in 24 hours and have found it very helpful. Formally I had been using Frontpage and find myself crazed by the limitations of wizards etc. I also connect to an Access database.The issue that I've literally spent days at is the fact that my ability to write to the Access database via the page that I created in VWD 2005 seems to be limited to my local computer. Everything works fine on the local computer. When I ftp the files to my website I get a "server error in / application". I've tried this on two sites that I have websites on. One is 1and 1 webhosting and the other is ixwebhosting. Both support asp code. ixwebhosting has ensured that the database is not readonly and that I users have web permissions, yet I still get the server error. 1and1 has a webfile utility where I can set the permission which I did, yet it still isn't working. I'm blind with fatigue and frustration from all the time I've spent on this. What am I missing?Thanks,Leesha

Link to post
Share on other sites

I notice you didn't mention the connection string so I would assume that is your problem. On your local box, your connection string will be configured for the location of your Access Db somewhere on your C: drive. When you deploy the site to a remote host, you need to set the connection string to suit that environment. You need to check out the hosting service's own documentation about Db connection strings, as it depends on where they locate your Db and so forth.If you still have problems, look again at the detail of the "server error" as that contains the reason. Post that server error text here if still stuck.

Link to post
Share on other sites

THANK YOU SO MUCH FOR YOUR RESPONSE! I am blind with fatigue from working at this and am determined NOT to let it beat me. I'm just clueless!>>I notice you didn't mention the connection string so I would assume that is your problem. I'm not sure where/how to access this to get it published. I have been working in Frontpage and in an attempt to learn ASP got started with ASP.net not realizing it was different than ASP until today. This is very foreign territory to me. Since my websites have all been built in FP, my "goal" was to generate the forms that need to connect to the Access database in VWD 2005 and then import them into Frontpage and upload them to the site. The goal is/was to get away from the wizards in FP to connect to the database as they limit what I can do and I am at this point dependent on code that is generated for me. My question is, is this even possible or will I need to move away from FP and work totally in ASP.net.My next question is whether or not there is a step in deploying/publishing from VWD that includes the connection string that I am missing?>>When you deploy the site to a remote host, you need to set the connection string to suit that environment. I thought I did that with the web.config file that is generated by VWD. This is the code I put in.<configuration> <appSettings/> <connectionStrings> <add name="ConnectionString" connectionString="Driver={Microsoft Access Driver (*.mdb)};Dbq=URL=App_Data/Feedback.mdb;Uid=Admin;Pwd=;ExtendedAnsiSQL=1" /> </connectionStrings> <system.web>>>You need to check out the hosting service's own documentation about Db connection strings, as it depends on where they locate your Db and so forth.I use both 1and1.com and ixwebhosting. ixwebhosting allows me to set up my odbc connections with I did and they've assured me that they've done their part to allow the files to be written to. 1and1 had a webfile utility that allows me to edit writing privileges which I have already done. The thing that confuses me is that I am able to view the table data so I know the connection is being made, I can't edit it or write to it.>>If you still have problems, look again at the detail of the "server error" as that contains the reason. Post that server error text here if still stuck.Here is the server error:Server Error in '/campcarekids' Application.--------------------------------------------------------------------------------Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".<!-- Web.Config Configuration File --><configuration> <system.web> <customErrors mode="Off"/> </system.web></configuration> Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.<!-- Web.Config Configuration File --><configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web></configuration> Thank you so much!Leesha

Link to post
Share on other sites
ixwebhosting allows me to set up my odbc connections with I did and they've assured me that they've done their part to allow the files to be written to. 1and1 had a webfile utility that allows me to edit writing privileges which I have already done. The thing that confuses me is that I am able to view the table data so I know the connection is being made, I can't edit it or write to it.
OK, so you have set up the connection string as you showed, and it is working, at least to let you view the data, so the problem may well be something else such as the writing privileges or a coding bug. We can't see what yet, because the "server error" you've posted shows that the error details themselves are being suppressed to suit a live environment. So you need to tweak your web.config to allow the error details to be displayed while you are trying to solve the problem. That's what it's trying to tell you. Inside the <system.web> configuration element, add a <customErrors> element (or edit any existing <customErrors> element) to look like this:
<system.web>...	<customErrors mode="Off"/>...</system.web>

Then retry. The "server error" will then include the error information, with details of what the actual error is.

Link to post
Share on other sites

Hi,Well after researching things last night I foudn the 1and1 does support asp.net but not with links to an access database, which mine was so I'm assuming that is why I had write errors. I redid the form with a link the SQL Server Express Edition 2005 table and still received a server error. After entering in the code you gave me, this is what I get:Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.Source Error: Line 56: ASP.NET to identify an incoming user. Line 57: -->Line 58: <authentication mode="Forms" />Line 59: <!--Line 60: The <customErrors> section enables configuration Source File: E:\kunden\homepages\28\d196566577\campcarekids\asp.net files\web.config Line: 58 I'm not sure what this means or how to correct.Thanks!Leesha

Link to post
Share on other sites
Source File: E:\kunden\homepages\28\d196566577\campcarekids\asp.net files\web.config Line: 58
This error is happening for the following reason. Assuming your hosting service have done their job, they will have defined an application in IIS to correspond to your root folder. Therefore the implication is that you have deployed your ASP.NET app to a subfolder. This will not work. In environments where you have access to IIS, such as on your local box or a server where you have full control, you can use subfolders and configure IIS to use them. But otherwise you must deploy to the web root folder.
Link to post
Share on other sites

>> Therefore the implication is that you have deployed your ASP.NET app to a subfolder. This will not work. I had the files in a subfolder for organization purposes. Now I'm getting this error 26 related to connecting the database. After reading online re this error I found that not all hosting companies support sql server express. I contacted my hosting company and they support sql server 2005 and stated that the asp file needs to connect to that database. The only database that I can upload is an Access database but they don't support connecting asp pages to an Access database. Groan! So, now my question is how do I proceed from here? I don't have a problem purchassing the developer edition so I can work with files on my local computer vs live with the hosting company however I'm not sure if this is the way to proceed. What would you suggest?Thanks,Leesha

Link to post
Share on other sites

I'm not sure what you meant by

The only database that I can upload is an Access database
because you had said you'd changed it to a SQL Express one:
I foudn the 1and1 does support asp.net but not with links to an access database, which mine was so I'm assuming that is why I had write errors. I redid the form with a link the SQL Server Express Edition 2005 table and still received a server error.
I'm assuming you created a database using SQL Express and deployed it according to your hosting company's instructions. If not, you should now do that.
Now I'm getting this error 26 related to connecting the database. After reading online re this error I found that not all hosting companies support sql server express. I contacted my hosting company and they support sql server 2005 and stated that the asp file needs to connect to that database.
Fine--because a database created with SQL Express is fully compatible with SQL Server 2005! You just need to stop referring to SQL Express in your connection string. Set the connection string according to your hosting company's instructions.
Link to post
Share on other sites

I am in the process of having my hosting company check on their end to see if anything is interfering. While I'm waiting for their response, I have a question. Is Visual Web Developer 2005 Express Edition meant to only be used on my local computer with SQL Server 2005 Express Edition or can it be used on the server as well. I've seen a few posts / faq's that lead me to believe this is hte case and then I see a ton of posts about it working on websites.Thanks!

Link to post
Share on other sites
Is Visual Web Developer 2005 Express Edition meant to only be used on my local computer with SQL Server 2005 Express Edition or can it be used on the server as well.
Your hosting company has a webserver (IIS) that supports ASP.NET. Therefore, if you develop an ASP.NET website and deploy it to that webserver, it will work. This is true regardless of the development tool you use to create your website (for example, Visual Studio or Visual Web Developer).Similarly: your hosting company runs one or more instances of the SQL Server 2005 database engine. So if you create a SQL Server 2005 database (.mdf file) and deploy it to the hosting company (following their instructions to attach it), it will work. This is true regardless of the SQL Server 2005 edition you use to create your database (for example, SQL Express or SQL Server 2005).
Link to post
Share on other sites

>>....Therefore, if you develop an ASP.NET website and deploy it to that webserver, it will work. This is true regardless of the development tool you use to create your website (for example, Visual Studio or Visual Web Developer).This makes me feel better. At least I'm not spending all this time (It's been a week) in a futile attempt to get something to work that wasn't meant to.Thanks so much,Alicia

Link to post
Share on other sites

>>I notice you didn't mention the connection string so I would assume that is your problem. On your local box, your connection string will be configured for the location of your Access Db somewhere on your C: drive. When you deploy the site to a remote host, you need to set the connection string to suit that environment. You need to check out the hosting service's own documentation about Db connection strings, as it depends on where they locate your Db and so forth.Still plugging away at this. When I researched the faq's on my hosting compnay, I found this sample code for connecting to the database. The faq talked about connecting the mssql database on their server not to the mssql express one that I have uploaded (my understanding is that mssql express can be uploaded to sit in a folder in the root directory and doesn't need to be imported into the mssql database). I'm not sure how to edit this code to point to my express database. Also, would I put this at the top of EVERY form that accesse's the database, would it go in the web.cofig file and if so where, or can I do a file that then all other pages look to.<%@ Page Language="VB" %><script runat="server"> Sub Page_Data Dim oDR as System.Data.SQLClient.SQLDataReader Dim oCom As System.Data.SQLClient.SqlCommand Dim oConn as System.Data.SQLClient.SQLConnection try oConn = New System.Data.SQLClient.SQLConnection ("server=mssqlxxx.1and1.com; initial catalog=dbxxxxxxxxx;uid=dboxxxxxxxxx;pwd=xxxxxxxx") oConn.Open() oCom = New System.Data.SQLClient.SqlCommand() oCom.Connection = oConn oCom.CommandText = "SELECT * FROM products" oDR = oCom.ExecuteReader() While oDR.Read Response.Write(oDR.Item("id") & ", " & oDR.Item("price")) Response.Write("<BR/>") End While catch Response.Write("Error:" & err.Description) Finally oDR = Nothing oCom = Nothing oConn.Close() oConn = Nothing end try End Sub</script><html><title>Queries from the MS-SQL database with ASP</title><body bgcolor="FFFFFF"><h2>Query from table <b>products</b> with ASP.NET</h2><%Page_Data()%></body></html> server is the hostname.initial catalog is the database nameuid is the user namepwd is the password

Link to post
Share on other sites
I'm not sure how to edit this code to point to my express database. Also, would I put this at the top of EVERY form that accesse's the database, would it go in the web.cofig file and if so where, or can I do a file that then all other pages look to.
Any webform accessing the database needs code similar to that.
The faq talked about connecting the mssql database on their server not to the mssql express one that I have uploaded (my understanding is that mssql express can be uploaded to sit in a folder in the root directory and doesn't need to be imported into the mssql database).
Something needs clarifying here! The word database is frequently used indiscriminately for database server as well as database, and it can be very confusing. Consider: if you have SQL Express on your local box, that is a database server (or engine). Using it, you might create a database which you call DB1, and then you might create two more databases, DB2 and DB3. These are SQL Server 2005 databases.When you deploy your database you are not deploying SQL Express, because SQL Express is a database engine. What you are deploying is a SQL Server 2005 database. According to the 1and1 faqs, you need to create a backup (.bak) of your database and import it into their database server by following the instructions at How to import my Microsoft SQL database into 1&1 Microsoft SQL Server.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...