CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 ASP and SQL syntax

Print topic Send  topic

Author Message
OMAR
Posted: 11/11/2002, 11:06 AM

can any one tell me what is wrong with this I cannot see it
thanks
here is the error msg I get:
Microsoft JET Database Engine (0x80040E14)
Number of query values and destination fields are not the
and here is the script that I have:

Dim QuestionId, Mode
SurveyId = Request("SurveyId")
QuestionId = Request("QuestionId")
Mode = Request("Mode")

If IsGlobalAdmin <> True AND SecTypeId <> 2 Then
Response.Redirect ASPSurveyPath & "/Admin/Denied.asp"
End If

Dim Surveys
SQL = "SELECT * FROM Survey WHERE Survey.SurveyId = " & SurveyId & ";"
Set Surveys = Server.CreateObject("ADODB.Recordset")
Surveys.CursorType = 1
Surveys.Open SQL, Conn

If Mode = "Insert" Then
Dim Add
Set Add = Server.CreateObject("ADODB.Recordset")

Dim Sequence, Answer, CorrectAnswer,Points
Sequence = Replace(Request.Form("Sequence"),"'","''")
Answer = Replace(Request.Form("Answer"),"'","''")
CorrectAnswer = Request.Form("CorrectAnswer")

SQL = "INSERT INTO Answer (QuestionId, Sequence, Answer, CorrectAnswer) VALUES "
SQL = SQL & "(" & QuestionId & "," & Sequence & "," & Answer & "," & CorrectAnswer &","
If CorrectAnswer = "ON" Then
SQL = SQL & "True"
Else
SQL = SQL & "False"
End If
SQL = SQL & ");"
' Response.write SQL
Add.Open SQL, Conn
RonB
Posted: 11/12/2002, 12:24 AM

I don't know any asp but the first thing I thought was:
what happended wo the SurveyId value you set> Basicaly it seems to tell you that the number of fields in the table doesn't compare to the number of fields in your insert query . If surveyId is a field in the answer table, and it probably is because how else would you know for wich survey the answer was meant.
Again I dont know asp I do PHP but that's what looked strange to me. The error message is clear.
Ron
Francis Solomon
Posted: 11/12/2002, 6:20 AM

The error is in your SQL.

Your INSERT statement specifies 4 fields to be inserted (QuestionID, Sequence, Answer, CorrectAnswer), yet you pass 5 values to be inserted.

The JET driver, quite understandably, has no idea what to do with the 5th value. You either need to tell the driver the name of the field in which to place your final True/False value or remove the 5th value from the values list.

HTH.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.