主题:  INSERT INTO 语句的语法错误。

truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
注册:2002/6/12 17:51:54
#12005/1/10 13:33:04
fat32 磁盘分区,iis 5.0 ,xp 专业版

出错提示:
异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.oledb" %>
<script runat="server">

Sub Button1_Click(sender As Object, e As EventArgs)
dim dsn as string
dsn="provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("../database/db.mdb" & ";"
dim conn as oledbconnection=new oledbconnection(dsn)
conn.open
dim strsql as string
dim username,password,email as string
username=request.form("username"
password=request.form("password"
email=request.form("email"
strsql="insert into info(username,password,email) values('wang','262','wyongping@163.com')"
'strsql="insert into userinfo(username,password,email) values('"& username &"','"& password &"','"& email &"')"
dim cmd as oledbcommand=new oledbcommand(strsql,conn)
dim result_int as integer
cmd.executenonquery()
if result_int>=1 then
response.write("ok!"
else
response.write("error!"
end if
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<table height="150" width="300">
<tbody>
<tr>
<td>
用户:</td>
<td>
<asp:TextBox id="username" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
密码:</td>
<td>
<asp:TextBox id="password" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
电邮:</td>
<td>
<asp:TextBox id="email" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="提交"></asp:Button>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

编辑历史:[此帖最近一次被 truelove 编辑过(编辑时间:2005-01-10 14:56:12)]


蓝鲸

职务:版主
等级:5
金币:42.1
发贴:2614
注册:2001/12/20 15:57:57
#22005/1/10 14:44:59
老问题了,password是SQL固定词,[password]。另外你用.NET却用asp的方法,.NET使用文本框变量不提倡使用Request,而直接用
Dim strName As String = txtName.Text


非常大鱼

蓝鲸

职务:版主
等级:5
金币:42.1
发贴:2614
注册:2001/12/20 15:57:57
#32005/1/10 14:45:43
另请更正标题,否则删帖了。


非常大鱼

truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
注册:2002/6/12 17:51:54
#42005/1/11 13:49:58
已经排除问题了,非常感谢蓝鲸兄!