我在尝试使用应该有效的代码更新我的SQL数据库时遇到问题,我没有看到错误或者如何修复它。也许一组新的眼睛可能能够指出什么是错的。错误=
"参数化查询'(@ 0 nvarchar(3),@ 1 nvarchar(12),@ 2 nvarchar(8),@ 3 nvarchar(4),@ 4'期望参数' @ 8',未提供。"
代码如下:
Truck_Number = Request.Form["Truck_Number"];
Truck_Make = Request.Form["Truck_Make"];
Truck_Model = Request.Form["Truck_Model"];
Truck_Year = Request.Form["Truck_Year"];
Truck_Vin = Request.Form["Truck_Vin"];
Truck_Empty_Weight = Request.Form["Truck_Empty_Weight"];
Truck_Assigned_To = Request.Form["Truck_Assigned_To"];
Truck_Assigned_Date = Request.Form["Truck_Assigned_Date"];
Truck_Plate_Number = Request.Form["Truck_Plate_Number"];
Truck_IFTA_ID = Request.Form["Truck_IFTA_ID"];
Truck_HUT_ID = Request.Form["Truck_HUT_ID"];
Truck_Oregon_ID = Request.Form["Truck_Oregon_ID"];
Truck_New_Mexico_ID = Request.Form["Truck_New_Mexico_ID"];
Truck_Kentucky_ID = Request.Form["Truck_Kentucky_ID"];
Truck_Payment_Start_Date = Request.Form["Truck_Payment_Start_Date"];
Truck_Payment_Due_Date = Request.Form["Truck_Payment_Due_Date"];
Truck_Payment_Amount = Request.Form["Truck_Payment_Amount"];
Truck_Total_Payment = Request.Form["Truck_Total_Payment"];
Truck_Commission = Request.Form["Truck_Commission"];
var updateQueryString =@"UPDATE Trucks SET Truck_Number=@0,
Truck_Make=@1,
Truck_Model=@2,
Truck_Year=@3,
Truck_Vin=@8,
Truck_Empty_Weight=@5,
Truck_Assigned_To=@6,
Truck_Assigned_Date=@7,
Truck_Plate_Number=@8,
Truck_IFTA_ID=@9,
Truck_HUT_ID=@10,
Truck_Oregon_ID=@11,
Truck_New_Mexico_ID=@12,
Truck_Kentucky_ID=@13,
Truck_Payment_Start_Date=@14,
Truck_Payment_Due_Date=@15,
Truck_Payment_Amount=@16,
Truck_Total_Payment=@17,
Truck_Commission=@18 WHERE ID=@19";
db.Execute(updateQueryString,Truck_Number,Truck_Make,Truck_Model,Truck_Year,Truck_Vin,Truck_Empty_Weight,Truck_Assigned_To,Truck_Assigned_Date,Truck_Plate_Number,Truck_IFTA_ID,Truck_HUT_ID,Truck_Oregon_ID,Truck_New_Mexico_ID,Truck_Kentucky_ID,Truck_Payment_Start_Date,Truck_Payment_Due_Date,Truck_Payment_Amount,Truck_Total_Payment,Truck_Commission,ID);
Response.Redirect("truck_list.cshtml");
任何帮助以找出错误我会很感激!
答案 0 :(得分:1)
你已经两次列出了@ 8,并且你错过了@ 4。
答案 1 :(得分:0)
Truck_Vin=@8,
应为Truck_Vin=@4,