源代码如下:<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.sqlclient" %>
<%@ Page Language="VB" Debug="true" %>
<script language="VB" runat="server">
Sub Enter_Click(Sender As Object, E As EventArgs)
'建立Connection对象
Dim conn As New sqlConnection("server=(local);database=balanced;uid=sa;pwd=")
'建立Command对象
Dim strA,strB,strSql As String
strA="Insert Into msgboard(nickname,sex,pwd,msgtitle,msgtime"
strB=" Values('" & nickname.text & "','" & thesex.SelectedItem.value & "','" & msgtitle.text & "',#" & Now() & "#"
if trim(email.text)<>"" then                '如果电子邮件不为空,就执行
   strA=strA &",email"
   strB=strB & ",'" & email.text & "'"
end if   
If Trim(msgcontent.Text)<>"" Then               '如果内容不为空,就执行
strA=strA & ",msgcontent"
strB=strB & ",'" & msgcontent.Text & "'"
End If
strSql=strA & ")" & strB & ")"
Dim cmd As New sqlCommand(strSql, conn)
Dim Exp As Exception
Try
'执行操作,添加留言
conn.open()                             
cmd.ExecuteNonQuery()
conn.close()                            
Response.Redirect("msgnote1.aspx")         '正常添加后,返回留言页面
Catch Exp 
throw(exp)
End Try
End Sub
</script>
<html>
<body>
<br><br>
<h4 align="center">留言板</h4>
<p>
<h4 align="center">请留下你宝贵的言语</h4>
<center>
<form runat="server">
<table border="1" width="80%" cellpading="2" cellspacing="0">
<tr>
<td>昵称:</td>
<td><asp:textbox id="nickname" runat="server"/>
<asp:RequiredFieldValidator id="Require1" ControlToValidate="nickname" ErrorMessage="必须输入昵称" Display="Static" runat="server" /></td>
</tr>
<tr>
<td>性别:</td>
<td>
<asp:DropDownList id="thesex"  runat="server">
<asp:ListItem value="male">男</asp:ListItem>
<asp:ListItem value="female">女</asp:ListItem>
<asp:ListItem value="secret">保密</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>E-mail:</td>
<td><asp:textbox id="email" columns="40" runat="server"/></td>
</tr>
<asp:RegularExpressionValidator id="emailRegexVal"
            ControlToValidate="email"
            ErrorMessage="电子邮件。"
            Display="Static"
            ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
            Font-Name="Arial" Font-Size="11"
            runat=server>
            不是有效的电子邮件地址。必须遵循此格式:[email protected]
        </asp:RegularExpressionValidator>
<tr>
<td>主题:</td>
<td><asp:textbox id="msgtitle" columns="50" runat="server"/><asp:RequiredFieldValidator id="Require2" ControlToValidate="msgtitle" ErrorMessage="必须输入主题" Display="Static" runat="server" /></td>
</tr>
<tr>
<td>内容:</td>
<td><asp:textbox id="msgcontent" textmode="multiline" columns="40" rows="4" runat="server"/></td>
</tr>
<tr>
<td></td>
<td><asp:button id="Enter" text=" 提 交 留 言 " onClick="Enter_Click" runat="server"/></td>
<td><input type="reset" value=" 取 消 留 言 ">
</tr>
</table>
<table width="400" border="0" cellspacing="0" cellpadding="3" align="center">
<tr>
<td>
<asp:Label id="statues" runat="server" />
</td>
</tr>
</table>
<asp:datagrid id="myDatagrid" runat="server" bordercolor="black" borderwidth="1" WIDTH="760" ALIGN="center"
gridlines="both" AutoGenerateColumns="true" visible="false" />
</form>
<a href="note1.aspx">察看所有留言</a>
</center>
</body>
</html>
运行后错误显示如下:“/sss”应用程序中的服务器错误。
--------------------------------------------------------------------------------在此上下文中不允许使用 '#2005'。此处只允许使用常量、表达式或变量。不允许使用列名。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 在此上下文中不允许使用 '#2005'。此处只允许使用常量、表达式或变量。不允许使用列名。源错误: 
行 28:  Response.Redirect("msgnote1.aspx")         '正常添加后,返回留言页面
行 29:  Catch Exp 
行 30:  throw(exp)
行 31:  End Try
行 32: End Sub
 源文件: D:\My document\My Webs\平衡计分卡\留言板\msgnote.aspx    行: 30 堆栈跟踪: 
[SqlException: 在此上下文中不允许使用 '#2005'。此处只允许使用常量、表达式或变量。不允许使用列名。]
   ASP.msgnote_aspx.Enter_Click(Object Sender, EventArgs E) in D:\My document\My Webs\平衡计分卡\留言板\msgnote.aspx:30
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1277 
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573