日期:2014-05-18  浏览次数:20476 次

列名或所提供值的数目与表定义不匹配
出错部分代码如下:
C# code

        string title = TitleText.Text.ToString();
        string neirong = Request.Form["neirong"];
        string beizhu = Request.Form["beizhu"];
        string maker = "00000";//Session["UserID"].ToString();
        string time = DateTime.Now.ToString();

        string insertString = "insert into other_task values('" + maker + "','"+ title + "','" + neirong + "','" + beizhu + "','" + time + ",null," + "null" + "')";
        string sqlString = "Data Source=localhost;Initial Catalog=gsc;User ID=sa;PassWord=123456";

            SqlConnection insertConn = new SqlConnection(sqlString);
            insertConn.Open();

            SqlCommand insertComm = new SqlCommand(insertString, insertConn);
            insertComm.ExecuteNonQuery();//此行提示错误



数据库表结构创建脚本如下:
SQL code

CREATE TABLE [dbo].[other_task](
    [TaskID] [int] IDENTITY(1,1) NOT NULL,
    [Maker] [char](5) NULL,
    [Title] [nvarchar](255) NULL,
    [neirong] [nvarchar](255) NULL,
    [beizhu] [nvarchar](255) NULL,
    [tbegin] [smalldatetime] NULL,
    [tend] [smalldatetime] NULL,
    [finflag] [bit] NULL
) ON [PRIMARY]



请问是哪里的格式不对了?datetime的问题还是不能直接用null?

------解决方案--------------------
探讨
出错部分代码如下:
C# code

string title = TitleText.Text.ToString();
string neirong = Request.Form["neirong"];
string beizhu = Request.Form["beizhu"];
string maker = "00000";……

------解决方案--------------------
探讨

前台textarea代码如下:
HTML code

<tr>
<td>任务内容:</td>
<td>
<textarea id="neirong" runat="server" cols="72" rows="8" name="neirong" ></textarea>
</td>
……