必须声明标量变量错误

 SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@LogNo", logNo.Text), 
                new SqlParameter("@LogDate", logDate.Text),
                new SqlParameter("@ItemAdvisor", itemAdvisor.Text), 
                new SqlParameter("@ItemName", itemName.Text),
            new SqlParameter("@WorkContent",workContent.Text),
            new SqlParameter("@NextWork",nextWork.Text),
            new SqlParameter("@RiskEvaluation",riskEvaluation.Text),
            new SqlParameter("@TodayWorkload",todayWorkload.Text),
            new SqlParameter("@CommonWorkload",commonWorkload.Text),
            new SqlParameter("@OvertimeWorkload",overtimeWorkload.Text),
            new SqlParameter("@SumWorkload",sumWorkload.Text),
            new SqlParameter("@RemainderWorkload",remainderWorkload.Text),
            new SqlParameter("@Remarks",remarks.Text)};
            strsql = "insert into bjcsjskj (logNo,logDate,itemAdvisor,itemName,workContent,
nextWork,riskEvaluation,todayWorkload,commonWorkload,overtimeWorkload,sumWorkload
,remainderWorkload,remarks,isExamineAndApprove) values('@LogNo','@LogDate','@ItemAdvisor',
'@ItemName','@WorkContent','@NextWork','@RiskEvaluation','@TodayWorkload','@CommonWorkload',
'@OvertimeWorkload','@SumWorkload','@RemainderWorkload','@Remarks','0')";

 解决办法如下:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">

改成

<asp:GridView ID="GridView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource1">

就可以了,也就是把ID定义为主键

注意:DataKeyNames是一个数组,可以用多个字段组成主键(即关键字,唯一的,用来标识一条记录)。

 

你可能感兴趣的:(必须声明标量变量错误)