Hi, I'm just developing v2 of my app and I'm passing a session parameter from the version into a SelectIncrementalUpdates/InsertsCommand so that I can retrieve a select list of fields based on which build of my app is being used (in the newer version of my app, there are some extra fields that i want to retrieve).
Anyway, from v2 of my app, I'm passing a session parameter called '@BuildNumber' so that my stored procedure can do some conditional logic when it is building the select list.
The first version of my app doesn't have this BuildNumber session parameter, so when it is synchronizing, I am getting an error (and the sync is failing):
SessionVariableException: Unable to set session parameters in DbServerSyncProvider. Cannot obtain the value for command parameter '@BuildNumber' The server code is:
IncidentsSyncAdapter.SelectIncrementalInsertsCommand = new
System.Data.SqlClient.SqlCommand();<br/>
IncidentsSyncAdapter.SelectIncrementalInsertsCommand.CommandText = "syncIncidents_SelectIncrementalInserts"
; <br/>
IncidentsSyncAdapter.SelectIncrementalInsertsCommand.CommandType = System.Data.CommandType.StoredProcedure;<br/>
IncidentsSyncAdapter.SelectIncrementalInsertsCommand.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@UpdatedBy_SyncClientID"
, SqlDbType.UniqueIdentifier)); <br/>
IncidentsSyncAdapter.SelectIncrementalInsertsCommand.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@sync_last_received_anchor"
, System.Data.SqlDbType.VarBinary));<br/>
IncidentsSyncAdapter.SelectIncrementalInsertsCommand.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@sync_new_received_anchor"
, System.Data.SqlDbType.VarBinary));<br/>
IncidentsSyncAdapter.SelectIncrementalInsertsCommand.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@BuildNumber"
, System.Data.SqlDbType.Int));<br/>
How can I test that this BuildNumber value exists before I try to add the SqlParameter into the command object? I'd like to do something like:
if (BuildNumber parameter doesn't exist) { set a default value, or alternatively, don't try to add it to the SqlParameter collection as I have a default value set in the stored proc }
Is this possible to do? Any help appreciated...
Jon