开发者

SQL/Sync Framework: When executing stored procedure I see parameter listed twice when using SQL Profiler on Db

So let's say I have a simple table containing 2 columns Shipment_ID (uniqueidentifier) and Completed_Date (datetime, Allows Nulls).

I also have a simple stored procedure that will be used by the Sync framework that will take 3 parameters to match these columns and a sync row. Defaulting the Completed_Date column to Null as follows:

Procedure [Insert_Shipment_From_Sync]
  @Shipment_ID uniqueidentifier,
  @Completed_Date = NULL,
  @sync_row_count as int OUTPUT
Begin
  ...
End

The sync adapter is setup to have an InsertCommand as follows:

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);

When I go to profile the sync in action using the SQL Profiler I see the following occur during my 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

Which causes me to get:

ErrorMessage:Procedure or function Ins开发者_JS百科ert_Shipment_From_Sync has too many arguments specified. Error:System.Data.SqlClient.SqlException (0x80131904): Procedure or function Insert_Shipment_From_Sync has too many arguments specified.

Why is the Completed_Date being inserted twice into the parameter list? Is it a result of defaulting the column Completed_Sync to 'Allow Nulls'? Is it a result of providing a default parameter for the procedure (@Completed_Sync = NULL)?


By searching for @Completed_Sync_Date, I found that I actually had it defined twice for the InsertCommand and UpdateCommand, which in the end caused it the error seen above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜