Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Someone Help! Weird error!
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Someone Help! Weird error!

 Post Reply Post Reply
Author
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Topic: Someone Help! Weird error!
    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>



Edited by pmormr
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post 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.

 

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 23 April 2003 at 4:52pm
i'm kinda new to this, how would i know to use single quotes?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.