If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Textfile Pains

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-02, 11:35
colzboppo colzboppo is offline
Registered User
 
Join Date: Sep 2001
Location: Chester
Posts: 5
Textfile Pains

Good day,
I have a problem...
It is an INSERT new record page, that does this into a text file...
It has worked before - so I know it's possible... Can anyone spot the mistake?

Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Text Driver] Too few parameters. Expected 5.
/sales/_admin/new.asp, line 59


And it is on this page...


<%@Language="VBscript"%>
<%
'Gets the last record if page has just been loaded
if Cstr(request.form("submittion")) <> "true" then

sDSNFile = "csv.dsn"
sPath = "D:\Webs\t-shirtprinter.com\data\"
' Time to construct our dynamic DSN

sDSN = "FileDSN=" & sPath & sDSNFile & _
";DefaultDir=" & sPath & _
";DBQ=" & sPath & ";"

' Building Data Connection
Dim Conn, rs
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open sDSN

Dim sql
sql = "SELECT * FROM stock.txt"
set rs = conn.execute(sql)

'stores to an array
rsGR = rs.getrows()

'closes conn
rs.close
set rs = nothing

'Gets last Record ID
LastR = UBound(rsGR,2)
firstCol = LBound(rsGR,1)
lastID = rsGR(firstCol,LastR)

'formats last ID
lastID = lastID + 1
response.write lastID

'Else as in form has been posted
Else
sPath = "D:\Webs\t-shirtprinter.com\data\"
' Time to construct our dynamic DSN
sDSNFile = "csv.dsn"
sDSN = "FileDSN=" & sPath & sDSNFile & _
";DefaultDir=" & sPath & _
";DBQ=" & sPath & ";"

editTable = "stock.txt"
fields = "ID,colour,garment,style,quality,size,quantity "
Values = request.form("ID") & "," & request.form("colour") & "," & request.form("garment") & "," & request.form("style") & "," & request.form("quality") & "," & request.form("size") & "," & request.form("quantity")

editConnection = sDSN
editQuery = "INSERT into " & editTable & " (" & fields & ") values (" & Values & ")"
response.write editQuery
' execute the insert
Set editCmd = Server.CreateObject("ADODB.Command")
editCmd.ActiveConnection = editConnection
editCmd.CommandText = editQuery
editCmd.Execute
editCmd.ActiveConnection.Close
response.redirect("default.asp")
End If

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- #BeginTemplate "/Templates/Default.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->
<title>New stock record</title>
<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../../default.css" type="text/css">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><!-- #BeginEditable "Title" -->New Stock record<!-- #EndEditable --></h1>
<table width="100%" border="0" cellpadding="6" cellspacing="0" name="body">
<tr>
<td><!-- #BeginEditable "body" -->
<h6>Please fill all the details in</h6>
<form name="form1" method="post" action="" onSubmit="MM_validateForm('colour','','R','style', '','R','quantity','','RisNum');return document.MM_returnValue">
<table width="150" border="0" cellpadding="4" cellspacing="0">
<tr>
<td>
<p>Colour</p>
</td>
<td>
<input type="text" name="colour" size="20">
</td>
</tr>
<tr>
<td>Size</td>
<td>
<select name="size">
<option value="XXL" selected>XXL</option>
<option value="XL">XL</option>
<option value="L">L</option>
<option value="M">M</option>
<option value="S">S</option>
</select>
</td>
</tr>
<tr>
<td>Quality</td>
<td>
<select name="quality">
<option value="perfect" selected>Perfect</option>
<option value="irregular">Seconds</option>
</select>
</td>
</tr>
<tr>
<td>Garment</td>
<td>
<select name="garment">
<option value="t-shirt">T-shirt</option>
<option value="sweatshirt">Sweatshirt</option>
<option value="skinny">Womens skinny fit top</option>
</select>
</td>
</tr>
<tr>
<td>Style</td>
<td>
<input type="text" name="style" size="20">
</td>
</tr>
<tr>
<td>Quantity</td>
<td>
<input type="text" name="quantity" size="20">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
<input type="hidden" name="submittion" value="true">
<input type="hidden" name="ID" value="<%=lastID%>">
</td>
</tr>
</table>
</form>
<p>&nbsp; </p>
<!-- #EndEditable --></td>
</tr>
<tr>
<td class="Links"><a href="http://www.t-shirtprinter.com">home</a> | <a href="../../services">services</a>
| <a href="../../sales">sales</a> | <a href="../../links">links</a> | <a href="../../contact.htm">contact</a></td>
</tr>
</table>
</body>
<!-- #EndTemplate -->
</html>
Reply With Quote
  #2 (permalink)  
Old 09-16-02, 14:06
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Please post the db schema for the table you are trying to insert into. Also, you say this has worked before - how is it different now - what data is being typed into the fields ? Will it fail every time now ? If these records are being inserted into a text file - how did you define the dsn ? Double check your column names and table name.
Reply With Quote
  #3 (permalink)  
Old 09-17-02, 03:17
colzboppo colzboppo is offline
Registered User
 
Join Date: Sep 2001
Location: Chester
Posts: 5
monkeys

Thanks,
I fixed it this morning...
It was 'missing' apostrophe's.

But now I get an error like this for another page...
Active Server Pages, ASP 0113 (0x80004005)


On this blasted page > All it does is displays a form > which then picks a category of records to display

<%@language="VBscript"%>
<%
If request.form("quality") <> "" then
sDSNFile = "csv.dsn"

sPath = "D:\Webs\t-shirtprinter.com\data\"
' Time to construct our dynamic DSN

sDSN = "FileDSN=" & sPath & sDSNFile & _
";DefaultDir=" & sPath & _
";DBQ=" & sPath & ";"

' Building Data Connection
Dim Conn, rs
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open sDSN

Dim sql
sql = "SELECT * FROM stock.txt WHERE quality LIKE '" & request.form("quality") & "'"
set rs = conn.execute(sql)
response.write sql
End If

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- #BeginTemplate "/Templates/Default.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->
<title>T-shirtPrinter.com ADMINISTRATION</title>
<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../../default.css" type="text/css">
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><!-- #BeginEditable "Title" -->Administration Home<!-- #EndEditable --></h1>
<table width="100%" border="0" cellpadding="6" cellspacing="0" name="body">
<tr>
<td><!-- #BeginEditable "body" -->
<form name="form1" method="post" action="default.asp">
Please choose Quality
<select name="quality" onChange="this.form.submit()">
<option>select...</option>
<option value="perfect">Perfect</option>
<option value="irregular">Seconds</option>
</select>
</form>
<% If request.form("quality") <> "" then %>
<table width="95%" cellpadding="3" border="0" cellspacing="0">
<tr>
<td width="16%"><b>ID</b></td>
<td width="16%"><b>Garment</b></td>
<td width="16%"><b>Size</b></td>
<td width="16%"><b>Style</b></td>
<td width="16%"><b>Quantity</b></td>
<td width="16%"><b>admin</b></td>
</tr>
<%
col = ""
Do while not rs.EOF
If col = "" then
col = "#ccffff"
else
col = ""
End If
%>
<tr bgcolor="<%=col%>">
<td width="16%"><%=rs("ID")%></td>
<td width="16%"><%=rs("garment")%></td>
<td width="16%"><%=rs("size")%></td>
<td width="16%"><%=rs("style")%></td>
<td width="16%"><%=rs("quantity")%></td>
<td width="16%"><a href="update.asp?ID=<%=rs("ID")%>">Change</a> | <a href="delete.asp?ID=<%=rs("ID")%>">Delete</a></td>
</tr>
<%
Loop
%>
</table>
<% End If %>
<!-- #EndEditable --></td>
</tr>
<tr>
<td class="Links"><a href="http://www.t-shirtprinter.com">home</a> | <a href="../../services">services</a>
| <a href="../../sales">sales</a> | <a href="../../links">links</a> | <a href="../../contact.htm">contact</a></td>
</tr>
</table>
</body>
<!-- #EndTemplate -->
</html>
<%
If request.form("quality") <> "" then
rs.close
set rs = nothing
end if
%>
Reply With Quote
  #4 (permalink)  
Old 09-18-02, 14:00
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
How long does it take your sql statement to run ? And when you are rendering your web page, how long does it take before you receive this error ?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On