Forums

This topic is locked

santax error in INERST INTO statment

Posted 11 Jun 2001 00:53:43
1
has voted
11 Jun 2001 00:53:43 suhail kaleem posted:
when ever i put the update or insert beh in my page i get a error

santax error in UPDATE statment
and
santax error in INERST INTO statment

WHY IS THAT ?

Replies

Replied 12 Jun 2001 16:12:13
12 Jun 2001 16:12:13 Jay Blanchard replied:
Can you supply the entire UPDATE statement? It is hard to answer your question without more information.

Replied 13 Jun 2001 01:09:48
13 Jun 2001 01:09:48 suhail kaleem replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Can you supply the entire UPDATE statement? It is hard to answer your question without more information.


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>



here is the query string :

MM_editConnection = MM_poll_STRING
MM_editTable = "tblPolls"
MM_editColumn = "id_no"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "admin.asp"
MM_fieldsStr = "Question|value|Selection_1|value|Selection_2|value|Selection_3|value|Selection_4|value|Selection_5|value|Votes_1|value|Votes_2|value|Votes_3|value|Votes_4|value|Votes_5|value|Date|value"
MM_columnsStr = "Question|',none,''|Selection_1|',none,''|Selection_2|',none,''|Selection_3|',none,''|Selection_4|',none,''|Selection_5|',none,''|Votes_1|none,none,NULL|Votes_2|none,none,NULL|Votes_3|none,none,NULL|Votes_4|none,none,NULL|Votes_5|none,none,NULL|Date|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"


and it gave me error on the below line when its excute the update function' execute the update


Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
error -------- &gt; MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close


below is the complet scrip for ye better understanding


&lt;%@LANGUAGE="VBSCRIPT"%&gt;
&lt;!--#include file="../Connections/poll.asp" --&gt;
&lt;%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL")
If (Request.QueryString &lt;&gt; "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%&gt;
&lt;%
' *** Update Record: set variables

If (CStr(Request("MM_update") &lt;&gt; "" And CStr(Request("MM_recordId") &lt;&gt; "" Then

MM_editConnection = MM_poll_STRING
MM_editTable = "tblPolls"
MM_editColumn = "id_no"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "admin.asp"
MM_fieldsStr = "Question|value|Selection_1|value|Selection_2|value|Selection_3|value|Selection_4|value|Selection_5|value|Votes_1|value|Votes_2|value|Votes_3|value|Votes_4|value|Votes_5|value|Date|value"
MM_columnsStr = "Question|',none,''|Selection_1|',none,''|Selection_2|',none,''|Selection_3|',none,''|Selection_4|',none,''|Selection_5|',none,''|Votes_1|none,none,NULL|Votes_2|none,none,NULL|Votes_3|none,none,NULL|Votes_4|none,none,NULL|Votes_5|none,none,NULL|Date|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"

' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl &lt;&gt; "" And Request.QueryString &lt;&gt; "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString &lt;&gt; "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%&gt;
&lt;%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update") &lt;&gt; "" And CStr(Request("MM_recordId") &lt;&gt; "" Then

' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal &lt;&gt; "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i &lt;&gt; LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl &lt;&gt; "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%&gt;
&lt;%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Request.QueryString("id_no" &lt;&gt; "" then Recordset1__MMColParam = Request.QueryString("id_no"
%&gt;
&lt;%
set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_poll_STRING
Recordset1.Source = "SELECT * FROM tblPolls WHERE id_no = " + Replace(Recordset1__MMColParam, "'", "''" + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;form name="Form1" action="&lt;%=MM_editAction%&gt;" method="POST"&gt;
&lt;table border="1" cellspacing="4" cellpadding="1" align="center" bordercolor="#0000FF"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table border="0"&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Question&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Question" value="&lt;%=(Recordset1.Fields.Item("Question".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Selection_1&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Selection_1" value="&lt;%=(Recordset1.Fields.Item("Selection_1".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Selection_2&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Selection_2" value="&lt;%=(Recordset1.Fields.Item("Selection_2".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Selection_3&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Selection_3" value="&lt;%=(Recordset1.Fields.Item("Selection_3".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Selection_4&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Selection_4" value="&lt;%=(Recordset1.Fields.Item("Selection_4".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Selection_5&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Selection_5" value="&lt;%=(Recordset1.Fields.Item("Selection_5".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Votes_1&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Votes_1" value="&lt;%=(Recordset1.Fields.Item("Votes_1".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Votes_2&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Votes_2" value="&lt;%=(Recordset1.Fields.Item("Votes_2".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Votes_3&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Votes_3" value="&lt;%=(Recordset1.Fields.Item("Votes_3".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Votes_4&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Votes_4" value="&lt;%=(Recordset1.Fields.Item("Votes_4".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Votes_5&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Votes_5" value="&lt;%=(Recordset1.Fields.Item("Votes_5".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Date&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="Date" value="&lt;%=(Recordset1.Fields.Item("Date".Value)%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p align="center"&gt;
&lt;input type="submit" name="Submit" value="Save"&gt;
&lt;/p&gt;
&lt;input type="hidden" name="MM_update" value="true"&gt;
&lt;input type="hidden" name="MM_recordId" value="&lt;%= Recordset1.Fields.Item("id_no".Value %&gt;"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
Recordset1.Close()
%&gt;
<font face='Georgia'></font id='Georgia'><font color=red></font id=red>

Replied 13 Jun 2001 03:14:03
13 Jun 2001 03:14:03 Waldo Smeets replied:
Please please please don't post such large codes in this board... it's absolutely useless. You'd better email the page to the person who wants it.

Next time I'll delete these posts. Sorry.

Waldo Smeets - www.UDzone.com Webmaster
------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
------------------------------------------
Replied 13 Jun 2001 03:23:13
13 Jun 2001 03:23:13 suhail kaleem replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Please please please don't post such large codes in this board... it's absolutely useless. You'd better email the page to the person who wants it.

Next time I'll delete these posts. Sorry.

Waldo Smeets - www.UDzone.com Webmaster
------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
------------------------------------------
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>


i am very sorry i will not do that again


now whould u help me ?

Replied 13 Jun 2001 17:08:02
13 Jun 2001 17:08:02 Jay Blanchard replied:
Have you modified any of the code on this page?
Can you prepare a stand alone INSERT INTO statement and get it to work?
Do you have permissions to UPDATE or INSERT?
Have you tried recreating this page from scratch?

These are the troubleshooting measures I would perform.

Waldo, it was my fault he submitted so much code. I should have been more clear, I just wanted the section of code where the UPDATE statement was. I'll be more clear next time.

Replied 13 Jun 2001 18:22:11
13 Jun 2001 18:22:11 Waldo Smeets replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Waldo, it was my fault he submitted so much code. I should have been more clear, I just wanted the section of code where the UPDATE statement was. I'll be more clear next time.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

No problem saintsguy.

Waldo Smeets - www.UDzone.com Webmaster
------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
------------------------------------------
Replied 14 Jun 2001 03:35:42
14 Jun 2001 03:35:42 suhail kaleem replied:
hey saintsguy Thank you for taking the blame on you -

yes i have tried to make the page from the scrach- i also tried to apply the update -insert sb to a new page it doest not work there -

i also reinstal ud - and kept the same configration dir - problem prisits i have many extension installed i think they must have done some thing wrong or they must be conflicting with each other or with ud , it will take me a lot of time to rinstall all the extension -

i just wanted to know that if i can get configration dir from u or any peorson who is reading this - who alreday have extension installed - just copy the config dir to my email or upload it some where -

thank you saintsguy.



Replied 14 Jun 2001 17:04:18
14 Jun 2001 17:04:18 Jay Blanchard replied:
It's not your extensions or your UD install, nor is it a configuration problem. I suspect, quite strongly, that it is a permissions problem. Which database are you using? Can you run a stand-alone SQL statement in a query analyzer? If so, you need to try this to see if you have permissions.

Wait...I don't see a statement like this in your code
-----
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""
-----
This is the actual INSERT code from the server behaviors.

Try creating a stand alone INSERT page without any other queries, let me know what happens.

Replied 15 Jun 2001 03:55:35
15 Jun 2001 03:55:35 suhail kaleem replied:
<b>WHAT I AM DOING WRONG !!!</b>

i installed ud in different drive - and applied update-insert sb to a seprate file - but it still gave me santax error in update -inerst into satament .

now what ? i cant fix this - what should i do ?????

suhailkaleem

Replied 15 Jun 2001 04:10:51
15 Jun 2001 04:10:51 suhail kaleem replied:
one more thing .
there is no problem with the premmision because i can insert record(custom code not ud code) but can't update it -got error .

if i put custom code its inserts record as well as update it but when ud genrate code then it nor inserts nor updates the db itr gave error. -if my ud was courrpt then i have installed ud again but still not working .

suhailkaleem

Replied 15 Jun 2001 16:35:22
15 Jun 2001 16:35:22 Jay Blanchard replied:
I don't think there is a problem with UD...what version are you using? What database backend are you using? Do you have more than one behavior in one page? If you do it will not work. Does your database support the UPDATE and SET verbs? I wish I could be of more help....



Replied 16 Jun 2001 02:45:22
16 Jun 2001 02:45:22 suhail kaleem replied:
hurray !
i found what i was doing wrong.

there was date feild in my db - which defaulkt value was set to now () . now when i made the update page by putting the update sb in the page i aslo included the date feild in the page- so when ever i run the page on iis 5 it gave me error - i just removed the dtae felid from my page its worked fine now no error -

so one more question - why cant i update the date feild in my db.<b></b><b></b><b></b>

Reply to this topic