Jump to content
Nuraida Anisa Bt Sobri

Syntax Error In Insert Into Statement

Recommended Posts

Assalamualaikum semua,

saya nak minta bantuan sikit....saya tengah buat satu system guna dreamweaver dan asp..Tapi ada problem masa nak insert record dalam database(Access)keluar error type macam ni

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

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

bantu saya ok tq... smile.gif

Share this post


Link to post
Share on other sites

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#include file="Connections/staff1.asp" -->

<%

' *** 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")) = "notice") Then

MM_editConnection = MM_staff1_STRING

MM_editTable = "notice"

MM_editRedirectUrl = "viewmemo.asp"

MM_fieldsStr = "fromnote|value|Tonote|value|TopicNote|value|note|value"

MM_columnsStr = "From|',none,''|To|',none,''|Topic|',none,''|note1|',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

MM_editCmd.Execute

MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then

Response.Redirect(MM_editRedirectUrl)

End If

End If

End If

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Main</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

.style7 {font-size: 14px}

.style8 {font-size: 12px}

body {

background-color: #CCCCCC;

}

a:link {

text-decoration: none;

color: #333333;

}

a:visited {

text-decoration: none;

color: #333333;

}

a:hover {

text-decoration: none;

color: #0000FF;

}

a:active {

text-decoration: none;

color: #FF0000;

}

.style9 {color: #FF0000}

.style10 {color: #FFFFFF}

-->

</style>

</head>

<body>

<table width="768" height="420" border="1" align="center">

<tr>

<th height="414" colspan="6" align="center" valign="baseline" bordercolor="#0000FF" bgcolor="#FFFFFF" scope="col"><table width="751" height="99" border="1" bordercolor="#99CCFF" bgcolor="#3399FF">

<tr>

<th width="301" bgcolor="#99CCFF" scope="col">&nbsp;</th>

<th width="434" align="center" valign="top" bgcolor="#99CCFF" scope="col"><p class="style8">Welcome To Team Support System </p>

<p class="style8">&nbsp;</p></th>

</tr>

</table>

<table width="749" border="1" bordercolor="#FF9900" bgcolor="#FFFFFF">

<tr>

<th width="124" bordercolor="#0000FF" bgcolor="#FF9900" scope="col"><span class="style7">Notice Board </span></th>

<th width="124" bordercolor="#0000FF" bgcolor="#FF9900" scope="col"><span class="style7">Message</span></th>

<th width="124" bordercolor="#0000FF" bgcolor="#FF9900" scope="col"><span class="style7">Memo</span></th>

<th width="124" bordercolor="#0000FF" bgcolor="#FF9900" scope="col"><span class="style7">Discussion</span></th>

<th width="124" bordercolor="#0000FF" bgcolor="#FF9900" scope="col">Task</th>

<th width="89" bordercolor="#0000FF" bgcolor="#FF9900" scope="col">Logout</th>

</tr>

</table> <table width="750" height="191" border="1">

<tr>

<th width="200" height="185" align="center" valign="top" scope="col"><p class="style9">Notice Board</p>

<table width="200" border="1">

<tr>

<th bordercolor="#FFFF66" bgcolor="#3366FF" scope="col"><span class="style10">Actions</span></th>

</tr>

</table> <p class="style9">&nbsp; </p></th>

<th width="534" align="center" valign="top" scope="col"><p>&nbsp;</p>

<table width="345" height="238" border="1" bordercolor="#000000">

<tr>

<th width="563" height="23" bordercolor="#9999FF" bgcolor="#3366FF" scope="col"><div align="left" class="style10">Edit Notice </div></th>

</tr>

<tr><form METHOD="POST" ACTION="<%=MM_editAction%>" name="notice" id="notice">

<table width="318" border="1" bordercolor="#CCCCCC">

<tr align="center" valign="middle">

<th width="103" bordercolor="#666666" bgcolor="#CCCCCC" scope="col"><div align="justify">

<p>From:</p>

</div></th>

<th width="199" scope="col">

<div align="justify">

<p>

<input name="fromnote" type="text" id="fromnote">

</p>

</div></th>

</tr>

<tr align="center" valign="middle">

<th bordercolor="#666666" bgcolor="#CCCCCC" scope="row"><div align="justify">

<p>To:</p>

</div></th>

<td>

<div align="justify">

<p>

<input name="Tonote" type="text" id="Tonote">

</p>

</div></td>

</tr>

<tr align="center" valign="middle">

<th bordercolor="#666666" bgcolor="#CCCCCC" scope="row"><div align="justify">

<p>Topic:</p>

</div></th>

<td>

<div align="justify">

<p>

<input name="TopicNote" type="text" id="TopicNote">

</p>

</div></td>

</tr>

<tr align="center" valign="middle">

<th height="171" bordercolor="#666666" bgcolor="#CCCCCC" scope="row"><div align="justify">

<p>Note:</p>

</div></th>

<td>

<div align="justify">

<p id="note" name="note">

<textarea name="note" cols="40" rows="10" id="note"></textarea>

</p>

</div></td>

</tr>

<tr>

<th colspan="2" scope="row"><div align="center">

<input type="submit" name="Submit" value="Submit">

<input name="reset" type="reset" id="reset" value="Reset">

</div></th>

</tr>

</table>

<input type="hidden" name="MM_insert" value="notice">

</form>

<th height="207" align="left" valign="top" scope="row"></th>

</tr>

</table> <p>&nbsp;</p></th>

</tr>

</table>

<p>&nbsp;</p></th>

<th width="22" align="center" valign="top" bordercolor="#0000FF" bgcolor="#FFFFFF" scope="col">&nbsp;</th>

</tr>

</table>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

</body>

</html>

error ada at line 116 cang color merah

Share this post


Link to post
Share on other sites

no. dah ade le.

1. dreamweaver ape yang ko gun?

2. ni mesti ko buat insert record, pastu ade la ko edit ape2 cam tambah field ke ubah nama field ke, kan?

3. try delete semua kod2 insert record tu, pastu start dari mula (untuk step2 insert record dalam dreamweaver). pasal kengkadang kalo ko ubah ape2 lepas ko dah gune insert record function dalam dreamweaver nanti kod die jadi tak betul.

Edited by C-Fu

Share this post


Link to post
Share on other sites

cara yg paling senang+keji+dirty utk setelkan problem ni, buang semua code yg berkaitan dengan asp, tinggalkan base HTML tu je, pastu buat balik dari mula insert record tu - mcm C-Fu kata tu.

konon-konon ada problem kat

MM_editCmd.Execute
tu tapi sebenarnya tak pun. code dreamweaver tu sendiri yg dh messed up. kalau guna wizard mmg mcm gini. redha je la dik .. smile.gif

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...