Click to See Complete Forum and Search --> : [RESOLVED] Problem adding new record to database


bliss72
09-07-2006, 08:48 AM
Hello,

I've done a bit of searching on this issue and the solutions aren't working for me, so I'm posting here.

I'm creating a registration page using Dreamweaver 8 & ASP pages. I am receiving "Error Type:Provider (0x80004005) Unspecified error /www/wholesale/reg/index.asp, line 104

Line 104 is: MM_editCmd.ActiveConnection = MM_editConnection;

Here is the rest of my code below. Any help is very much appreciated!!


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../../../WA_eCart/WA_eCart_Definition_JS.asp" -->
<!--#include file="../../../WA_eCart/WA_eCart1_JS.asp" -->
<!--#include file="../../../Connections/connBabyFace.asp" -->
<%
// *** 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 = "";
%>
<%
// *** Redirect if username exists
var MM_flag="MM_insert";
if (String(Request(MM_flag)) != "undefined") {
var MM_dupKeyRedirect="username_error.asp";
var MM_rsKeyConnection=MM_connBabyFace_STRING;
var MM_dupKeyUsernameValue = String(Request.Form("username"));
var MM_dupKeySQL = "SELECT username FROM users WHERE username='" + MM_dupKeyUsernameValue.replace(/'/g, "''") + "'"
var MM_adodbRecordset = "ADODB.Recordset";
var MM_rsKey = Server.CreateObject(MM_adodbRecordset);
MM_rsKey.ActiveConnection = MM_rsKeyConnection;
MM_rsKey.Source = MM_dupKeySQL;
MM_rsKey.CursorType=0;
MM_rsKey.CursorLocation=2;
MM_rsKey.LockType=3;
MM_rsKey.Open();
if (!MM_rsKey.EOF || !MM_rsKey.BOF) {
// the username was found - can not add the requested username
var MM_qsChar = "?";
if (MM_dupKeyRedirect.indexOf("?") >= 0) MM_qsChar = "&";
MM_dupKeyRedirect = MM_dupKeyRedirect + MM_qsChar + "requsername=" + MM_dupKeyUsernameValue;
Response.Redirect(MM_dupKeyRedirect);
}
MM_rsKey.Close();
}
%>
<%
// *** Insert Record: set variables

if (String(Request("MM_insert")) == "wholesale_reg") {

var MM_editConnection = MM_connBabyFace_STRING;
var MM_editTable = "users";
var MM_editRedirectUrl = "thankyou.asp";
var MM_fieldsStr = "username|value|pass|value|taxpayerid|value|companyname|value|email|value|firstname|value|lastname|va lue|address1|value|address2|value|city|value|state|value|zip|value|country|value|phone_land|value|ph one_cell|value|email_updates|value|usergroup|value";
var MM_columnsStr = "username|',none,''|pass|',none,''|taxpayerid|',none,''|companyName|',none,''|email|',none,''|firstNa me|',none,''|lastName|',none,''|address1|',none,''|address2|',none,''|city|',none,''|state|',none,'' |zip_postalcode|',none,''|country|',none,''|phone_landline|',none,''|phone_cell|',none,''|email_upda tes|none,1,0|usergroup|',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);
}
}

}
%>
<%
// WA eCart Redirect
if (WA_eCart1_redirStr != "") {
Response.Redirect(WA_eCart1_redirStr);
}
%>

bliss72
09-08-2006, 01:40 PM
I figured out the problem. I'm posting this in case other people have this problem.

It is a "permissions" problem with the database. The problem that I had with XP is that XP defaults to hiding the "security tab" when you right click on a folder or file in Windows Explorer. This takes away your ability to set the correct permissions to write to your database.

Here is a link to Microsoft on how to fix this problem - http://support.microsoft.com/kb/307874/en-us

(In Windows Explorer go to Tools | Folder Options | View | last item - Use simple file sharing (Recommended) - uncheck this box!!)

Once it is fixed:
- right click on the folder where your database is and click Properties
- go to security tab, click on Internet Guest Account, click on Read & Write permissions
- click apply
- do the same for your own profile on your computer so that you can use it locally

Do this for the folder that your database is in as well as right clicking on the database file and going the same thing.

Additionally, when you are testing this locally, you might need to exit Dreamweaver because there is a duplicate copy of the datbase that is locked and you could get the same error message.

Also there is a fix to upgrade Dreamweaver to 8.0.2. which has some problems with server behaviors. NOTE!! When installing the update, do not cancel out of it or else you will have to reinstall Dreamweaver again (I made that mistake). You will need your original install disk of DW. There is a workaround though in these details:

http://www.adobe.com/cfusion/knowledgebase/index.cfm?event=view&id=KC.581a553c&extid=581a553c&dialogID=168376713&iterationID=1&sessionID=48307b98ba0534672387&stateID=1+0+168402197&mode=simple

Good luck.