 |
| Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 22nd, 2004, 09:41 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Access database won't update?
Hello, i was hoping that someone could help me with this database problem. I have a dsn connection to my access database that works fine, but when i try to update it through a form on my website it won't work and i get a page with an internal server error. I have also updated the database in access and it will not show any new updates in the dreamweaver database pannel. When i open the database directly in access the records show up fine. I have updated both databases in local view and in my local root folder. but still nothing happens. Could anyone please help me? thanks jula
here is the code for my form which won't update
<form method="POST" action="<%=MM_editAction%>" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">CustomerID:</td>
<td>
<input type="text" name="CustomerID" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">ContactFirstName:</td>
<td>
<input type="text" name="ContactFirstName" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">ContactLastName:</td>
<td>
<input type="text" name="ContactLastName" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">BillingAddress:</td>
<td>
<input type="text" name="BillingAddress" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">City:</td>
<td>
<input type="text" name="City" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">StateOrProvince:</td>
<td>
<input type="text" name="StateOrProvince" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">PostalCode:</td>
<td>
<input type="text" name="PostalCode" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Country/Region:</td>
<td>
<input type="text" name="CountryRegion" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">PhoneNumber:</td>
<td>
<input type="text" name="PhoneNumber" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">EmailAddress:</td>
<td>
<input type="text" name="EmailAddress" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td>
<input type="submit" value="Insert record">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
|
|

September 22nd, 2004, 12:43 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I'd say if you're having troubles updating a database, it makes more sense to post the ASP code than the HTML, don't you think?? ;)
To get the detailed error message, check out this FAQ:
http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=264
Then post the error and the code that causes the error, so we can take a look....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Rub 'Til It Bleeds by P.J. Harvey (Track 4 from the album: Rid Of Me) What's This?
|
|

September 22nd, 2004, 05:13 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello Imar, I'm new to asp, i hope this helps
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
// *** Edit Operations: declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}
// boolean to abort record edit
var MM_abortEdit = false;
// query string to execute
var MM_editQuery = "";
%>
<%
// *** Insert Record: set variables
if (String(Request("MM_insert")) == "form1") {
var MM_editConnection = MM_customer_STRING;
var MM_editTable = "Customers";
var MM_editRedirectUrl = "aboutus.asp";
var MM_fieldsStr = "CustomerID|value|ContactFirstName|value|ContactLa stName|value|BillingAddress|value|City|value|State OrProvince|value|PostalCode|value|CountryRegion|va lue|PhoneNumber|value|EmailAddress|value";
var MM_columnsStr = "CustomerID|none,none,NULL|ContactFirstName|',none ,''|ContactLastName|',none,''|BillingAddress|',non e,''|City|',none,''|StateOrProvince|',none,''|Post alCode|',none,''|Country/Region|',none,''|PhoneNumber|',none,''|EmailAddres s|',none,''";
// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");
// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}
// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it
if (String(Request("MM_insert")) != "undefined") {
// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";
if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}
}
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_customer_STRING;
Recordset1.Source = "SELECT * FROM Customers";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
And all my settings are the same as the error FAQ link you gave me, and it still comes up with the same error
HTTP 500 - Internal server error
Internet Explorer
any ideas? cheers jula
|
|

September 23rd, 2004, 01:02 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Tat's weird. You should get detailed info when you change the settings in IE. Can you test a different type of browser and see if you get a different error message?
Are you running your own Web server? The error may be caused by a security issue where the Web server account (IUSR_MachineName) does not have permissions to read and/or write from the database....
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

September 23rd, 2004, 08:42 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello, yeh i am running my own web server but it has permissons to the database. When i first set up the connection it wouldn't show any tables so i went
through it setting up the permissons, and then i could see the tables. I don't understand why it won't update though, anyway i'll keep trying cheers
|
|

September 24th, 2004, 10:24 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
To what account did you grant access? Your account alone is not enough; the Web server needs access as well.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Strangers by Portishead (Track 3 from the album: Dummy) What's This?
|
|

September 26th, 2004, 07:36 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi, How do i grant access for the web server?, i thought giving it permissions through IIS was enough.
|
|

September 26th, 2004, 07:53 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
No, that's not enough. The Web server (usually the IUSR_MachineName account) needs to be able to read and write to the files on the (NTFS) disk as well.
Check out this FAQ for a detailed explanation: http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=290
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

September 26th, 2004, 05:46 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello Imar, It's all working now, i followed the FAQ you gave me and
it all works now. Thankyou so much, i can stop pulling my hair out now cheers jula
|
|
 |