注册 登录
编程论坛 ASP.NET技术论坛

沟通从从语法开始(insert into语法错误)

tm_ma 发布于 2007-03-31 16:13, 846 次点击

IE说:Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。
_____________________________________________

程序:
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<script language="vb" runat="server">
sub enter_Click(sender as object,e as eventargs)
dim conn as new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("../databace/wwwlink.mdb"))
dim sql as string
sql="insert into wwwlink(sitename,url,intro,grade,submit_date) values('" & sitename.text & "','" & url.text & "','" & intro.text & "'," & cint(grade.selecteditem.text) & " , #" &now() &"#"
dim cmd as new oledbcommand(sql,conn)
conn.open()
cmd.executenonquery()
conn.close()
message.text="提交成功"
end sub
</script>
辛苦了!!!

6 回复
#2
skyland842007-04-02 11:28
VB ?看是没有问题! 用就有问题了~!
#3
scindy2007-04-02 11:56
#" &now() &"# 改成:#" & now() &"#

试试,加一空格!!!






#4
bygg2007-04-02 12:36
你的grade字段是什么类型的??
#5
tm_ma2007-04-04 18:42
以下是引用scindy在2007-4-2 11:56:23的发言:
#" &now() &"# 改成:#" & now() &"#

试试,加一空格!!!






我断网了几天
他说的对,但是还是不行,有出现一个新的错误
____________________________操作必须使用一个可更新的查询
想了很久,一直不懂!我更新记录也不行!

#6
tel19822007-04-05 08:14
这应该是权限的设置有问题,你可以这一这样做:右键点击数据库的属性,在里面找到安全选项,然后找到everyone选项,把它的权限放到最大就可以了,如果没有这个选项,那么就进行添加,然后再以上面所说就可以了。
#7
fgwuhen2007-04-05 08:19

是不是字段的类型不相符,将sql语句显示出来看看? message.text=sql

[此贴子已经被作者于2007-4-5 8:20:48编辑过]

1