主题:  实在是找不出哪里出错了(asp.net vb.net)

truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#12005/3/21 13:48:13
<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.oledb" %>
<script language="vb" runat="server">

    sub button_click(sender as object,e as eventargs)
        dim request_username as string=TextBox1.text.trim()
        dim request_company as string=TextBox2.text.trim()
        dim request_add as string=TextBox3.text.trim()
        dim request_tel as string=TextBox4.text.trim()
        dim request_fax as string=TextBox5.text.trim()
        dim request_linkman as string=TextBox6.text.trim()
        dim request_email as string=TextBox7.text.trim()
        dim request_website as string=TextBox8.text.trim()
        dim request_content as string=TextBox9.text.trim()
        dim request_time as datetime=system.datetime.now
        dim dsn as string="Provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("db.mdb"
        dim conn as oledbconnection=new oledbconnection(dsn)
        conn.open()
        dim strsql as string="insert into guestbook(username,company,add,tel,fax,linkman,email,website,content,login_time) values('"& request_username &"','"& request_company &"','"& request_add &"','"& request_tel &"','"& request_fax &"','"& request_linkman &"','"& request_email &"','"& request_website &"','"& request_content &"','"& request_time &"')"
        dim cmd as oledbcommand=new oledbcommand(strsql,conn)
        cmd.executenonquery()
        end sub

</script>
<html>
<head></head>
<body>

<form runat="server">
<table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
<tbody>
<tr>
<td>
<img height="36" src="order1.gif" width="188" /><img height="36" src="wsdd.gif" width="131" /></td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="4" width="100%" align="center" border="0">
<tbody>
<tr>
<td width="60">
姓名:</td>
<td>
&nbsp;<asp:TextBox id="TextBox1" runat="server" Width="100px" MaxLength="4"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="姓名必须填写" ControlToValidate="TextBox1" Display="Dynamic">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
公司名称:</td>
<td>
&nbsp;<asp:TextBox id="TextBox2" runat="server" Width="350px"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="公司名称必须填写" ControlToValidate="TextBox2" Display="Dynamic">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
地址:</td>
<td>
&nbsp;<asp:TextBox id="TextBox3" runat="server" Width="350px"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ErrorMessage="地址必须填写" ControlToValidate="TextBox3" Display="Dynamic">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
电话:</td>
<td>
&nbsp;<asp:TextBox id="TextBox4" runat="server" Width="100px" MaxLength="13"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" ErrorMessage="电话必须填写" ControlToValidate="TextBox4" Display="Dynamic">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="电话填写错误" ControlToValidate="TextBox4" Display="Dynamic" ValidationExpression="[0-9]{3,4}[-]{1}[0-9]{7,8}">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
传真:</td>
<td>
&nbsp;<asp:TextBox id="TextBox5" runat="server" Width="100px" MaxLength="13"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator5" runat="server" ErrorMessage="传真号码输入错误" ControlToValidate="TextBox5" Display="Dynamic" ValidationExpression="[0-9]{3,4}[-]{1}[0-9]{7,8}">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
联系人:</td>
<td>
&nbsp;<asp:TextBox id="TextBox6" runat="server" Width="100px" MaxLength="4"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ErrorMessage="联系人必须填写" ControlToValidate="TextBox6" Display="Dynamic">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
电子邮件:</td>
<td>
&nbsp;<asp:TextBox id="TextBox7" runat="server" Width="200px"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ErrorMessage="电子邮件地址错误" ControlToValidate="TextBox7" Display="Dynamic" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
网址:</td>
<td>
&nbsp;<asp:TextBox id="TextBox8" runat="server" Width="200px"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator3" runat="server" ErrorMessage="网址输入错误" ControlToValidate="TextBox8" Display="Dynamic" ValidationExpression="((http)://)?(((([\d]+\.)+){3}[\d]+(/[\w./]+)?)|([a-z]\w*((\.\w+)+){2,})([/][\w.~]*)*)">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
内容:</td>
<td>
&nbsp;<asp:TextBox id="TextBox9" runat="server" TextMode="MultiLine" Width="360px" Rows="8"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator6" runat="server" ErrorMessage="内容必须填写" ControlToValidate="TextBox9" Display="Dynamic">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;&nbsp;<asp:Button onclick="button_click" id="Button" runat="server" Text="提交"></asp:Button>
<asp:ValidationSummary id="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False"></asp:ValidationSummary>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

提示出错的语句是:cmd.executenonquery()
尝试无数次了,还是出错,盼高手指点。



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#22005/3/21 14:05:20
错误提示是什么?打印sql语句看看



truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#32005/3/21 14:07:05
已经打印过了,sql语句是正确的。。非常的奇怪。



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#42005/3/21 14:12:23
错误提示



truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#52005/3/21 14:14:54
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

INSERT INTO 语句的语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

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

源错误:


行 20:         dim strsql as string="insert into guestbook(username,company,add,tel,fax,linkman,email,website,content,login_time) values('"& request_username &"','"& request_company &"','"& request_add &"','"& request_tel &"','"& request_fax &"','"& request_linkman &"','"& request_email &"','"& request_website &"','"& request_content &"','"& request_time &"')"
行 21:         dim cmd as oledbcommand=new oledbcommand(strsql,conn)
行 22:         cmd.executenonquery()
行 23:         end sub
行 24:


源文件: E:\www_root\asp.net\1.aspx 行: 22



大当家

职务:普通成员
等级:3
金币:1.0
发贴:767
#62005/3/21 14:42:03
注意保留字。

比如 ADD 之类的。



truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#72005/3/21 14:56:57
怎么说呢?
在这里要向回贴的各位网友道谢,谢谢你们这样热心。
谢谢"缺缺"和"大当家"
问题已经解决,果然是add的问题。



truelove

职务:普通成员
等级:1
金币:0.0
发贴:128
#82005/3/21 21:10:50
这个本来是address的意思,我简写成了add,所有错了。
换成address就好了。