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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP - Adding and Takeing

Status
Not open for further replies.

Johno2090

Programmer
May 3, 2002
31
GB
Ok here goes im making a program that calculates the stock of toners we have in our building everything works fine and wen users request the toners it enters there name printer and all there details into a spread sheet. Then i had the idea to make it automaticaly update the number of toners in the build ing instead of manually entering the data.

this is my code:
------------------------------------------------------------
<% OPTION EXPLICIT%>

<!--#include file=&quot;common.inc&quot; -->
<%
dim strdepartment
dim strNTUser, iPos, username
dim rsprint, rsprinters
dim strprintername, strNoTonerInHouse, strNoUsedToners

strNTUser = RTrim(Request.ServerVariables(&quot;LOGON_USER&quot;))
iPos = Len(strNTUser) - InStr(1, strNTUser,&quot;\&quot;,1)
strNTUser = Right(strNTUser, iPos)

if strntuser = &quot;GARETH.FINLAY&quot; or strntuser = &quot;Gareth.Finlay&quot; or strntuser = &quot;CHRIS.JOHNSON&quot; or strntuser = &quot;Chris.Johnson&quot; then

strNTUser = Request.form (&quot;UserName&quot;)

else

strNTUser = strNTUser

end if

strprintername = request.form (&quot;printername&quot;)
strdepartment = request.form (&quot;Department&quot;)

Set rsprint = Server.CreateObject(&quot;ADODB.Recordset&quot;)


strSQL = &quot;SELECT tblrequestedasp.* FROM tblrequestedasp &quot;

rsprint.CursorType = 2
rsprint.LockType = 3

rsprint.Open strSQL, strCon

rsprint.AddNew

rsprint.Fields(&quot;name&quot;) = strNTuser
rsprint.Fields(&quot;Printer&quot;) = strprintername
rsprint.Fields(&quot;team&quot;) = strdepartment

rsprint.Update
rsprint.close


strSQL = &quot;SELECT tprinters.printermake, tprinters.notonersinhouse, tprinters.nounusedtoners &quot;
strSQL = strSQL & &quot;FROM tprinters &quot;
strSQL = strSQL & &quot;WHERE tprinters.printermake =&quot; & &quot;'&quot; & strprintername & &quot;';&quot;

Set rsprinters = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsprinters.CursorType = 2
rsprinters.LockType = 3

rsprinters.Open strSQL, strCon

strNoTonersInHouse = rsprinters.Fields(&quot;NoTonerInHouse&quot;)-1
strNoUsedToners = rsprinters.Fields(&quot;NoUnUsedToners&quot;)+1
rsprinters.Fields(&quot;NoTonerInHouse&quot;) = strNoTonerInHouse
rsprinters.Fields(&quot;NoUnUsedToners&quot;) = strNoUsedToners

rsprinters.Update

rsprinters.close


'response.redirect &quot;logged.asp&quot;
response.write &quot;No Toners - &quot; & strnotonerinhouse
%> <br> <%
response.write &quot;No Used Toners - &quot; & strnousedtoners
%> <br> <%
response.write &quot;Printer Name - &quot; & strprintername
%> <br> <%
%>

------------------------------------------------------------

and this is the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/toner/PostRequest.asp, line 55

any ideas why it wont work cause im stumped!
 
I think you made a mistake with this sql statement :

strSQL = &quot;SELECT tprinters.printermake, tprinters.notonersinhouse, tprinters.nounusedtoners &quot;
strSQL = strSQL & &quot;FROM tprinters &quot;
strSQL = strSQL & &quot;WHERE tprinters.printermake =&quot; & &quot;'&quot; & strprintername & &quot;';&quot;

You should copy and paste this query and execute it directly in Access or SQLServer, it will give you a more detailed error message.

Jan If this response was usefull to you, please mark it with a Star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top