Forums

ASP

This topic is locked

HELP, INSERT RECORD ERROR??

Posted 28 Aug 2001 22:18:54
1
has voted
28 Aug 2001 22:18:54 Mario Cirillo posted:
<font face='Verdana'>ive made a simple form, and it should insert some records into the db, but it comes up with this error, Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

please help

Could you e-mail me at


thanks.</font id='Verdana'>

Maz

Replies

Replied 29 Aug 2001 09:35:55
29 Aug 2001 09:35:55 Viktor Farcic replied:
You must post your code here or give some more detail explanation about your problem.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<font face='Verdana'>ive made a simple form, and it should insert some records into the db, but it comes up with this error, Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

please help

Could you e-mail me at


thanks.</font id='Verdana'>

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

Replied 29 Aug 2001 20:29:16
29 Aug 2001 20:29:16 Mario Cirillo replied:
ok here is the code. if this isnt enough send me an e-mail and i will mail you the relevant files. i really appreciate your help. if this dont work could there be a error with my database?

&lt;%@LANGUAGE="VBSCRIPT"%&gt;
&lt;!--#include file="Connections/Intranet.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;%
' *** Insert Record: set variables

If (CStr(Request("MM_insert") &lt;&gt; "" Then

MM_editConnection = MM_Intranet_STRING
MM_editTable = "messages"
MM_editRedirectUrl = "default.asp"
MM_fieldsStr = "date|value|from|value|to|value|message|value"
MM_columnsStr = "Date|',none,''|From|',none,''|To|',none,''|Message|',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;%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert") &lt;&gt; "" Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
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_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""

If (Not MM_abortEdit) Then
' execute the insert
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

(thanks)

Mario

Maz
Replied 29 Aug 2001 21:27:10
29 Aug 2001 21:27:10 Viktor Farcic replied:
I don't see anything wrong with code you sent. Go to Advanced options in Internet Explorer and uncheck 'Show Friendly URLs'. After that load page again and send error message on this forum.
I had problems with date field in Access and that can be your problem. Try inserting these data without date.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
ok here is the code. if this isnt enough send me an e-mail and i will mail you the relevant files. i really appreciate your help. if this dont work could there be a error with my database?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Reply to this topic