Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL/Sync框架:在执行存储过程时,在Db上使用SQL探查器时,我会看到参数列出两次_Sql_Microsoft Sync Framework - Fatal编程技术网

SQL/Sync框架:在执行存储过程时,在Db上使用SQL探查器时,我会看到参数列出两次

SQL/Sync框架:在执行存储过程时,在Db上使用SQL探查器时,我会看到参数列出两次,sql,microsoft-sync-framework,Sql,Microsoft Sync Framework,假设我有一个简单的表,其中包含两列shipping_ID(uniqueidentifier)和Completed_Date(datetime,允许空值) 我还有一个简单的存储过程,将由Sync框架使用,它将使用3个参数来匹配这些列和一个Sync行。将Completed_Date列默认为Null,如下所示: Procedure [Insert_Shipment_From_Sync] @Shipment_ID uniqueidentifier, @Completed_Date = NULL,

假设我有一个简单的表,其中包含两列shipping_ID(uniqueidentifier)和Completed_Date(datetime,允许空值)

我还有一个简单的存储过程,将由Sync框架使用,它将使用3个参数来匹配这些列和一个Sync行。将Completed_Date列默认为Null,如下所示:

Procedure [Insert_Shipment_From_Sync]
  @Shipment_ID uniqueidentifier,
  @Completed_Date = NULL,
  @sync_row_count as int OUTPUT
Begin
  ...
End
this.InsertCommand = new System.Data.SqlClient.SqlCommand();
this.InsertCommand.CommandText = "[Insert_Shipment_From_Sync]";
this.InsertCommand.CommandType = System.Data.CommandType.StoredProcedure;
this.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Shipment_ID", System.Data.SqlDbType.UniqueIdentifier));
this.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Completed_Sync_Date", System.Data.SqlDbType.DateTime));
System.Data.SqlClient.SqlParameter insertcommand_sync_row_countParameter = new System.Data.SqlClient.SqlParameter("@sync_row_count", System.Data.SqlDbType.Int);
insertcommand_sync_row_countParameter.Direction = System.Data.ParameterDirection.Output;
this.InsertCommand.Parameters.Add(insertcommand_sync_row_countParameter);
同步适配器设置为具有InsertCommand,如下所示:

Procedure [Insert_Shipment_From_Sync]
  @Shipment_ID uniqueidentifier,
  @Completed_Date = NULL,
  @sync_row_count as int OUTPUT
Begin
  ...
End
this.InsertCommand = new System.Data.SqlClient.SqlCommand();
this.InsertCommand.CommandText = "[Insert_Shipment_From_Sync]";
this.InsertCommand.CommandType = System.Data.CommandType.StoredProcedure;
this.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Shipment_ID", System.Data.SqlDbType.UniqueIdentifier));
this.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Completed_Sync_Date", System.Data.SqlDbType.DateTime));
System.Data.SqlClient.SqlParameter insertcommand_sync_row_countParameter = new System.Data.SqlClient.SqlParameter("@sync_row_count", System.Data.SqlDbType.Int);
insertcommand_sync_row_countParameter.Direction = System.Data.ParameterDirection.Output;
this.InsertCommand.Parameters.Add(insertcommand_sync_row_countParameter);
当我使用SQL事件探查器分析正在运行的同步时,我看到在InsertCommand期间发生以下情况:

declare @p16 int
set @p16=NULL
exec [Insert_Shipment_From_Sync] 
  @Shipment_ID='some guid value',
  @Completed_Date=NULL,
  @sync_row_count=@p16 output,
  @Completed_Date=default
select @p16
这使我得到:

ErrorMessage:Insert\u Shipping\u From\u Sync的过程或函数指定的参数太多。错误:System.Data.SqlClient.SqlException(0x80131904):过程或函数Insert\u Shipping\u From\u Sync指定的参数太多


为什么在参数列表中插入两次完成日期?这是将列Completed_Sync默认为“Allow Nulls”的结果吗?这是为过程提供默认参数(@Completed\u Sync=NULL)的结果吗?

通过搜索@Completed\u Sync\u Date,我发现我实际上为InsertCommand和UpdateCommand定义了两次,这最终导致了上面所示的错误