有这样一个错误,希望会教教,谢谢!!代码如下:
<tr>
<td height="25" style="width: 12%"><div align="center"><font color="#ff0000">*</font>发布人:</div></td>
<td style="width: 620px"><asp:TextBox ID="new_author" runat="server" Width="260px"></asp:TextBox><font face="宋体">&nbsp;
<asp:requiredfieldvalidator id="user_check" runat="server" ControlToValidate="new_author" ErrorMessage="请输入姓名"></asp:requiredfieldvalidator></font></td>当我在发布人的文本框输入:数字时是可以的,但输入汉字或字母时就会出现一下错误:此处只允许使用常量、表达式或变量。不允许使用列名。源错误: 
行 35:             //创建数据库命令
行 36:             SqlCommand mycmd=new SqlCommand(strsql,myconn);
行 37:             mycmd.ExecuteNonQuery();
行 38:             myconn.Close();
行 39:             Response.Redirect("addnews.aspx");
这是为什么呢??
 

解决方案 »

  1.   

    检查strsql的写法是否正确
      

  2.   

    查看strsql
    '"+new_author.Text+"'
      

  3.   

    '"+new_author.Text+"'这个没错啊!!
      

  4.   

    LZ想把new_author.Text存进数据库中的那一列是什么类型?不会是数据类型的吧?
      

  5.   

    不是!是nvarchar,没有错吧??
      

  6.   

    检查数据字段的类型是什么?? Integer类型吗??? 如果是,则做一个只输入数字的验证
      

  7.   

    string strsql="Insert Into news(biaoti,neirong,shijian,zhaizi)";
                strsql=strsql+"Values("+"'"+title+"'";strsql=strsql+",'"+content+"'"+",'"+DateTime.Now+"',"+author+")";
    是这个,有什么错吗??