Print Page | Close Window

Someone Help! Weird error!

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1975
Printed Date: 29 March 2026 at 1:25pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Someone Help! Weird error!
Posted By: pmormr
Subject: Someone Help! Weird error!
Date Posted: 21 April 2003 at 7:15pm

I'm having a problem with the following code. It gives me the error,

Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/_scripts/_ASP/JokeoftheDay/selectionscript.asp, line 97


I've highlighted line 97 in red i'm positive all the fields are correct for the database. I've removed everything after the insert into statement and printed all the variables they all contain a valid value.

 <html>
<head>
<title>JOTD - Management System</title>
</head>
<body bgcolor="#000088" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<%
   'Copyright Paul Morgan: April 2003
   'Accesses the two joke and comic databases, generates
   'a random number to pick a record from each and copies
   'the random record values into the comic/joke of the
   'day database
  
   'Start timer
   Dim dblStartTime
   dblStartTime = Timer()
  
   'Set Randomizer function that returns a pesudo random
   'number
   Function random ()
   RANDOMIZE
   Dim randomnum
   randomnum = (rnd(1)) * 123456
   random = Round(randomnum)
   end function
  
   'Create connections to the joke of the day database
   Dim JOTD  
   Set JOTD = Server.CreateObject("ADODB.Connection") 
   JOTD.Mode = adModeReadWrite
   JOTD.Provider = "Microsoft.Jet.OLEDB.4.0"
   JOTD.Open ("c:\mydirectory\mysubdirectory\mydatabase.mdb")

   'Databases are linked so open up the two joke and comic recordsets
    
   Set jokers = Server.CreateObject("ADODB.Recordset")
   Set comicrs = Server.CreateObject("ADODB.Recordset")

   JokeRS.Open "SELECT * FROM LIST", JOTD
   ComicRS.Open "SELECT * FROM COMIC1", JOTD
  
   'Create two random numbers and put them into variables
   Dim rannum1
   Dim rannum2
   rannum1 = random () + 123
   rannum2 = random () + 100
  
   'Loop through the records in the jokes database using
   'the random number  
   jokers.movefirst
   comicrs.movefirst
     
   While rannum1 > 0  
     If jokers.EOF then
       jokers.movefirst
       jokers.movenext
       rannum1 = rannum1 - 1
     else
       JokeRS.movenext
       rannum1 = rannum1 - 1
     end if
   Wend
  
   'Do the same with the comics database
   While rannum2 > 0
     If comicrs.EOF then
       comicrs.movefirst
       comicrs.movenext
       rannum2 = rannum2 - 1
     else
       comicRS.movenext
       rannum2 = rannum2 - 1
     end if
   Wend
  
   'Now that the record pointer is on a random record
   'in each put the records into variables and put them into
   'the joke of the day database
   Dim xiD
   Dim cdate
   Dim cid
   Dim clink
   Dim jname
   Dim jdate
   Dim jlink
   xiD = 1
   cdate = comicrs.fields ("DateAdded")
   cid = comicrs.fields ("cid")
   clink = comicrs.fields ("comiclnk")
   jname = jokers.fields ("JokeName")
   jdate = jokers.fields ("AdditionDate")
   jlink = jokers.fields ("id")
  
   JOTD.Execute ("DELETE * FROM comic WHERE id = '1'")
   JOTD.Execute ("DELETE * FROM joke WHERE id = '1'")
  
   JOTD.Execute ("INSERT INTO comic (id, cid, da, link) VALUES (xid, cid, cdate, clink)")
   JOTD.Execute ("INSERT INTO joke (id, jname, da, link) VALUES (xid, jname, jdate, jlink)")
    
   Response.Write ("<font size=""6"">Management System - JOTD Selection System </font><hr>")
   Response.Write ("<div align=""center"">Program designed and tested by Paul A Morgan - Written in April 2003<hr>")
   Response.Write ("Comic and Joke of the day sucessfully changed.<hr></div>")
   Response.Write ("The comic of the day is now...<br>")
   Response.Write ("Comic ID number: " & comic.fields("cid"))
   Response.Write ("<br>")
   Response.Write ("Date added: " & comic.fields("da"))
   Response.Write ("<br>")
   Response.Write ("View link: <a href=""../../../../_stuff/_comics/_imagesrc/" & comic.fields("cid") & "Here </a>")
   Response.Write ("<hr>")
   Response.Write ("Joke of the day is now...<br>")
   Response.Write ("Joke Name: " & joke.fields("jname") &"<br>")
   Response.Write ("Date Added: " & joke.fields("da") &"<br>")
   Response.Write ("View Link: <a href=""../../../../_stuff/_jokes/_jokestorage/" & joke.fields("link") & "Here </a>")
  
   jokers.close
   comicrs.close
   JOTD.close
   Set jokers = nothing
   Set comicrs = nothing
   Set jotd = nothing
  
   Response.Write ("<br><br><font size=""2"">This page was generated in" & FormatNumber(Timer() - dblStartTime, 4) & "seconds </font>")
%>
</body>
</html>



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Replies:
Posted By: Bunce
Date Posted: 21 April 2003 at 10:05pm

This is quite a common error.

As with any database related error, place your statement into a variable and output that variable to the screen. 99% of the time you will see what the problem is straight away as you are seeing exactly what is being sent to the database.

In your situation, place:
strSQL = "INSERT INTO comic (id, cid, da, link) VALUES (xid, cid, cdate, clink)"
Reponse.Write strSQL
Response.End

Hint: Remember that strings need to be surrounded with quotes and dates with ##. What type of variables are cdate and clink.......

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: pmormr
Date Posted: 22 April 2003 at 1:20pm

cdate is a date in the format of mm/dd/yyyy and i'll try printing the line like you told me too.

 



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 23 April 2003 at 1:29pm
i still don't see anything wrong with the code. cdate is a date in the format of mm/dd/yyyy do i still need to surround that with

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: MorningZ
Date Posted: 23 April 2003 at 3:21pm

Dates in SQL need single quotes....

something you could have taken 10 seconds to code in and see for yourself



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: pmormr
Date Posted: 23 April 2003 at 4:52pm
i'm kinda new to this, how would i know to use single quotes?

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net