Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Record Problems

Status
Not open for further replies.

rubertoga

Technical User
Jan 4, 2003
22
US
New to dreamweaver mx. Using ASP with JavaScript

Built a form to send data to MS Access database and get the following error:
Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/ntsa/register.asp, line 76

As this is code auto generated by dreamweaver i have no idea what the problem is. Who said hand coding wasn't quicker?

Any ideas? Thanks
 
The code underlying the pages doesn't use a record set. I think the problem is to do with the connection string because that is what line 76 refers to.
 
can you display line 76? or a chunk of lines?


--------------------------------------------------------------------------------------------
aka.bmp
 
Wasn't sure if i was allowed to post code last time i did it i got a rolicking from someone - ah well at end of my tether now. Code from page with form and connection file is below.

Code on page with form (line 76 is in bold):

<%@LANGUAGE=&quot;JAVASCRIPT&quot;%>
<!--#include file=&quot;Connections/ntsa2.asp&quot; -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables(&quot;SCRIPT_NAME&quot;);
if (Request.QueryString) {
MM_editAction += &quot;?&quot; + Request.QueryString;
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = &quot;&quot;;
%>
<%
// *** Insert Record: set variables

if (String(Request(&quot;MM_insert&quot;)) == &quot;form1&quot;) {

var MM_editConnection = MM_ntsa2_STRING;
var MM_editTable = &quot;Technician&quot;;
var MM_editRedirectUrl = &quot;registerresults.asp&quot;;
var MM_fieldsStr = &quot;title|value|forename|value|surname|value|address|value|address2|value|town|value|county|value|postcode|value|phoneno|value|dob|value|gender|value|manicure|value|pedicure|value|nailart|value|extensions|value|email|value|supplier|value|trainer|value&quot;;
var MM_columnsStr = &quot;Title|',none,''|Forename|',none,''|Surname|',none,''|Address1|',none,''|Address2|',none,''|Town/City|',none,''|County|',none,''|Postcode|',none,''|Phonenumber|',none,''|Dateofbirth|',none,NULL|Gender|',none,''|Manicure|none,'Y','N'|Pedicure|none,'Y','N'|Nailart|none,'Y','N'|Extensions|none,'Y','N'|e-mail|',none,''|Nailart|',none,''|Trainerused|',none,''&quot;;

// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split(&quot;|&quot;);
var MM_columns = MM_columnsStr.split(&quot;|&quot;);

// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields));
}

// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?&quot;?&quot;:&quot;&&quot;) + Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it

if (String(Request(&quot;MM_insert&quot;)) != &quot;undefined&quot;) {

// create the sql insert statement
var MM_tableValues = &quot;&quot;, MM_dbValues = &quot;&quot;;
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(&quot;,&quot;);
var delim = (MM_typesArray[0] != &quot;none&quot;) ? MM_typesArray[0] : &quot;&quot;;
var altVal = (MM_typesArray[1] != &quot;none&quot;) ? MM_typesArray[1] : &quot;&quot;;
var emptyVal = (MM_typesArray[2] != &quot;none&quot;) ? MM_typesArray[2] : &quot;&quot;;
if (formVal == &quot;&quot; || formVal == &quot;undefined&quot;) {
formVal = emptyVal;
} else {
if (altVal != &quot;&quot;) {
formVal = altVal;
} else if (delim == &quot;'&quot;) { // escape quotes
formVal = &quot;'&quot; + formVal.replace(/'/g,&quot;''&quot;) + &quot;'&quot;;
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? &quot;,&quot; : &quot;&quot;) + MM_columns;
MM_dbValues += ((i != 0) ? &quot;,&quot; : &quot;&quot;) + formVal;
}
MM_editQuery = &quot;insert into &quot; + MM_editTable + &quot; (&quot; + MM_tableValues + &quot;) values (&quot; + MM_dbValues + &quot;)&quot;;

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);
}
}

}
%>

This is the code from the connection file:
<%
// FileName=&quot;Connection_ado_conn_string.htm&quot;
// Type=&quot;ADO&quot;
// DesigntimeType=&quot;ADO&quot;
// HTTP=&quot;true&quot;
// Catalog=&quot;&quot;
// Schema=&quot;&quot;
var MM_ntsa2_STRING = &quot;Driver={Microsoft Access Driver (*.mdb)};DBQ=&quot;&Server.MapPath(&quot;\\ntsa\\db\\NTSA2.mdb&quot;)
%>

found this link on the macromedia site too but i can't see anything like it in the complex code it generates unless its in relation to the MM_columnsStr .

Thanks 4 your time AKA :eek:)
 
a few pointers:
1.st use DSN less and use JET drivers for the best performance:
MM_MY_STRING = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;/fpdb/MY_DB.mdb&quot;) & &quot;

2nd. make your own SQL by using commands and cut down on code lenght:
(yes the &quot;audio&quot; is very &*%^%$^ but u get my point)

All the best!



> need more info?
:: don't click HERE ::
 
:)
well thank you.....the problem is finding time to make &quot;more of them&quot;...look at the time stamp at that machine (3:17 AM)
ignore the audio quality...bad language and all...it was supposed to be a tutorial for a friend of mine who was 120% sure it can NOT be done and that my code doesn't work and that &quot;my DW&quot; is a piece of **** of a program....seeing people is the sam trouble I published it.. &quot;as is&quot; :)
All the best!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top