I'm new to web design, only know how to use Dreamweaver. I tried to play with Connection string, Recordset, Insert Record and Binding. This is the error that I got when I tried to insert a record (submit a form) into my .mdb datbaase:
Script error detected at line 116.
Source line: MM_editCmd.Execute
Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
And this is my .asp file:
[code]
<%
@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "admin_life_addblog") Then
MM_editConnection = MM_connSongofsoul_STRING
MM_editTable = "Blogs"
MM_editRedirectUrl = "life.asp"
MM_fieldsStr = "Title|value|Date|value|Time|value|BlogEntry|value"
MM_columnsStr = "Title|',none,''|Date|',none,NULL|Time|',none,NULL|BlogEntry|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_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
[b]MM_editCmd.Execute[/b]
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
Song of Soul - Life_Admin Add Blog
Song of Soul - Life
= Exposure of the Inner
Me =
+ Add Blog Entry+
" method="POST" name="admin_life_addblog" id="admin_life_addblog">
[/code]
I've bold the statement in line 116.
P.s: After inserting the data into database, I should be re-directed to another .asp page.
Comments
Hide the .execute line for the time being.
[code]
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
Response.write "sql="&MM_editQuery&"
"
'MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
[/code]
I had tried this its working i m not getting any error.
but its not inserting any record to my access database.
how can i solve this problem?
Talha here. i m new in web designing.
i had tried this but it is not inserting any record in my access database.
how can i solve this problem??
[code]<%@LANGUAGE="VBSCRIPT"%>
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "form2") Then
MM_editConnection = MM_conn_info_STRING
MM_editTable = "[Coaching Centers]"
MM_editRedirectUrl = "thankyoucoaching.asp"
MM_fieldsStr = "Accept|value|Address|value|availablelabs|value|BuildingStatus|value|BuildingStructure|value|Campuses|value|Cell|value|CenterName|value|Commerce|value|ComputerScience|value|ContactPerson|value|EducationalInvironment|value|Email|value|FreeOffer|value|HomeEconomics|value|Humanities|value|Location|value|Medium|value|OfferedLevels|value|OtherInfo|value|PerMedical|value|Phone|value|PreEngineering|value|StudentRatio|value|URL|value|WebNecessary|value"
MM_columnsStr = "Accept|none,1,0|Address|',none,''|AvailableLabs|',none,''|BuildingStatus|',none,''|BuildingStructure|',none,''|Campuses|',none,''|Cell|',none,''|CenterName|',none,''|Commerce|none,1,0|ComputerScience|none,1,0|ContactPerson|',none,''|EducationalInvironment|',none,''|Email|',none,''|FreeOffer|',none,''|HomeEconomics|none,1,0|Humanities|none,1,0|Location|',none,''|Medium|',none,''|OfferedLevels|',none,''|OtherInfo|',none,''|Per-Medical|none,1,0|Phone|',none,''|Pre-Engineering|none,1,0|StudentRatio|',none,''|URL|',none,''|WebNecessary|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_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
[b] Response.write "sql="&MM_editQuery&"
"[/b]
'MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
Karachi Schools
Advertisements
" name="form2">
[/code]
Could you be more specific about it..
like what error message you got.
http://www.websitedesignerschennai.com/
actually i had tried what u told, the is not inserting any data to my access databese..
the was desplaying the form and when i submite it it shows the next page where i had redirect it but if i query my entry it does'nt show any thing..
please reply..
thanks & regards,
Shaikh Talha
shaikh.talha3@gmail.com
I tried but not get good result and i need best result in this topics..please reply us
Reg
[link=http://www.mayuri.co.in/]Web Design India[/link] | [link=http://www.webmayuri.com/]Web Design Company[/link]
Thank you verymuch.
G.Kiran
[link=http://www.visualsindia.com]
web design company chennai[/link], [link=http://www.visualsindia.com]web design india[/link],
[link=http://www/globaldent.in]dental software[/link],
[link=http://www.tirupatibalajidarshan.com]tirupati balaji darshan[/link], [link=http://www.onlineooty.com]ooty[/link]
[link=http://www.logicspice.com]Web Design Company[/link]
Thanks,
Ayishabanu
[link=http://www.websitedesigncompanychennai.com]Web Design Chennai[/link] | [link=http://www.xmediasolution.com]Web Designing Company[/link]
Thanks,
Ayishabanu
[link=http://www.websitedesigncompanychennai.com]Web Design Chennai[/link] | [link=http://www.xmediasolution.com]Web Designing Company[/link]