问题描述
程序或函数'insertReportLocalInvoiceDetailesTBL'需要参数'@REC_date',这是未提供的。
1我的代码在C#
for(int y = 0; y< ; dataGridView2.Rows.Count - 0; y ++)
{
SqlCommand cmd2 = new SqlCommand(insertReportLocalInvoiceDetailesTBL,con2);
cmd2.CommandType = System.Data.CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue( @ReportId_fk,txtInvoiceId.Text);
cmd2.Parameters.AddWithValue(@ REC_date,dataGridView2.Rows [y] .Cells [0] .Value);
cmd2.Parameters.AddWithValue(@ Invoice_Type,dataGridView2.Rows [y] .Cells [1] .Value);
cmd2.Parameters.AddWithValue(@ TTL_Pakege2,d ataGridView2.Rows [y] .Cells [2] .Value);
cmd2.Parameters.AddWithValue(@ GRN_Number,dataGridView2.Rows [y] .Cells [3] .Value);
cmd2.Parameters.AddWithValue(@ LPO_NO2,dataGridView2.Rows [y] .Cells [4] .Value);
cmd2.Parameters.AddWithValue(@ Supplier_Name ,dataGridView2.Rows [y] .Cells [5] .Value);
cmd2.Parameters.AddWithValue(@ DateInvoice,dataGridView2.Rows [y] .Cells [6] .Value) ;
cmd2.Parameters.AddWithValue(@ REQ_Number,dataGridView2.Rows [y] .Cells [7] .Value);
cmd2.Parameters.AddWithValue( @Item_Name,dataGridView2.Rows [y] .Cells [8] .Value);
cmd2.Parameters.AddWithValue(@ QTY,dataGridView2.Rows [y] .Cells [9]。值);
cmd2.Parameters.AddWithValue(@ Unit,dataGridView2.Rows [y] .Cells [10] .Value);
cmd2.ExecuteNonQuery();
}
这个我的程序:
ALTER proc [dbo]。[insertReportLocalInvoiceDetailesTBL]
@ReportId_fk int,
@REC_date nvarchar(150),
@Invoice_Type nvarchar(50),
@ TTL_Pakege2 nvarchar(50),
@GRN_Number int,
@ LPO_NO2 nvarchar(100),
@Supplier_Name nvarchar(100),
@DateInvoice nvarchar(100),
@REQ_Number int,
@Item_Name nvarchar(100),
@QTY浮动,
@Unit nvarchar(50)
as
开始
插入ReportLocalInvoiceDetailesTBL值(@ReportId_fk,@ REC_date,@ Invoice_Type,@ TTL_Pakege2,@ GRN_Number,@ LPO_NO2,@ Supplier_Name,@ DateInvoice,@ REQ_Number,@ Item_Name,@ QTY,@ Unit)
结束
Procedure or function 'insertReportLocalInvoiceDetailesTBL' expects parameter '@REC_date', which was not supplied.
1 This My Code In C#
for (int y = 0; y < dataGridView2.Rows.Count - 0; y++)
{
SqlCommand cmd2 = new SqlCommand("insertReportLocalInvoiceDetailesTBL", con2);
cmd2.CommandType = System.Data.CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@ReportId_fk", txtInvoiceId.Text);
cmd2.Parameters.AddWithValue("@REC_date", dataGridView2.Rows[y].Cells[0].Value);
cmd2.Parameters.AddWithValue("@Invoice_Type", dataGridView2.Rows[y].Cells[1].Value);
cmd2.Parameters.AddWithValue("@TTL_Pakege2", dataGridView2.Rows[y].Cells[2].Value);
cmd2.Parameters.AddWithValue("@GRN_Number", dataGridView2.Rows[y].Cells[3].Value);
cmd2.Parameters.AddWithValue("@LPO_NO2", dataGridView2.Rows[y].Cells[4].Value);
cmd2.Parameters.AddWithValue("@Supplier_Name", dataGridView2.Rows[y].Cells[5].Value);
cmd2.Parameters.AddWithValue("@DateInvoice", dataGridView2.Rows[y].Cells[6].Value);
cmd2.Parameters.AddWithValue("@REQ_Number", dataGridView2.Rows[y].Cells[7].Value);
cmd2.Parameters.AddWithValue("@Item_Name", dataGridView2.Rows[y].Cells[8].Value);
cmd2.Parameters.AddWithValue("@QTY", dataGridView2.Rows[y].Cells[9].Value);
cmd2.Parameters.AddWithValue("@Unit", dataGridView2.Rows[y].Cells[10].Value);
cmd2.ExecuteNonQuery();
}
This My Procedure:
ALTER proc [dbo].[insertReportLocalInvoiceDetailesTBL]
@ReportId_fk int,
@REC_date nvarchar(150),
@Invoice_Type nvarchar(50),
@TTL_Pakege2 nvarchar(50),
@GRN_Number int,
@LPO_NO2 nvarchar(100),
@Supplier_Name nvarchar(100),
@DateInvoice nvarchar(100),
@REQ_Number int,
@Item_Name nvarchar(100),
@QTY float,
@Unit nvarchar(50)
as
begin
insert into ReportLocalInvoiceDetailesTBL values (@ReportId_fk,@REC_date,@Invoice_Type,@TTL_Pakege2,@GRN_Number,@LPO_NO2,@Supplier_Name,@DateInvoice,@REQ_Number,@Item_Name,@QTY,@Unit)
end
推荐答案
cmd2.Parameters.AddWithValue("@REC_date", dataGridView2.Rows[y].Cells[0].Value);
错误消息暗示值你提供的是 null
,SP定义不接受NULL值。
The error message implies that the value you supply is null
, and the SP definition won't accept a NULL value.
这篇关于如何解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!