[Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句的语法错误。 asp网页出错 怎么解决那

高分请讲解下,[Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句的语法错误。 asp网页出错 怎么解决那?

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句的语法错误。
/tongyong/admin/admin_xiazai_neirong_add.asp, 第 39 行

浏览器类型:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; SE 2.X MetaSr 1.0

网页:
POST 83 ??? /tongyong/admin/admin_xiazai_neirong_add.asp

POST Data:
CLASSID=3&showname=Q&FILENAME=Q&TXTNAME=&NOTE=Q&button=%D4%F6%BC%D3&MM_insert=form1

代码:
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_conntongyong_STRING
MM_editCmd.CommandText = "INSERT INTO DOWNLOAD (CLASSID, SHOWNAME, FILENAME, TXTNAME, NOTE) VALUES (?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("CLASSID"), Request.Form("CLASSID"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("showname")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 100, Request.Form("FILENAME")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("TXTNAME")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 203, 1, 1073741823, Request.Form("NOTE")) ' adLongVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "/tongyong/admin/admin_xiazai_zong.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
最新回答
安和桥

2024-04-25 03:57:12

做作业的时候遇到的ACCESS数据库问题:
提取JSP页面数据使用JAVABEAN对数据进行数据库的插入操作:下面是JAVABEAN 文件
package com.ynu.steva.myblog;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
public class regist {
String ADBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String Conn="jdbc:odbc:myblog";
Connection connect=null;
ResultSet rs=null;
public void add(String name,String password,String Email)throws SQLException
{
try{Class.forName(ADBDriver);}
catch(java.lang.ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
connect=DriverManager.getConnection(Conn);
Statement stmt1=connect.createStatement();

Date date = new Date();
String year = String.valueOf(date.getYear()+1900);
String month = String.valueOf(date.getMonth()+1);
String day = String.valueOf(date.getDate());
String d = year + "-" + month + "-" + day;

String sql = "INSERT INTO person"
+"(name,password,Email,logtime)" //该属性是修改后的,
www.520fanhuan.com
以前是time属性,产生错误的原因的在ACCESS数据库中time是关键字所以不能作为变量使用,修改后题目错误得以解决
+"VALUES" +
"('"+name+"','"+password+"','"+Email+ "','" +
d+"')";
stmt1.executeUpdate(sql);
stmt1.close();
connect.close();
}
且奔赴

2024-04-25 02:33:22

ame,age)values("+aa+",'"+bb+"')"
改为
exec="insert into stud (name,age) values ('"&aa&"',"&bb&")"
傲骨

2024-04-25 04:40:35

应该是语句错误,把你的sql语句输出,然后在你数据库中执行一下,就可以找到哪儿的错误,然后修改好后,在代码中再修改就行
追问
我用的是ACCess数据库,要怎么把sql语句输出执行呢
追答
不管是什么数据库,你总能在类中用System.out.println(sql);这样的语句把语句输出到你的myeclipse控制台呀。
如果是存储过程也可以的,你可以输出你取得值,首先你得保证你取到的值应该能正常运行。