Try our conversational search powered by Generative AI!

Create Market with country "Netherlands"?

Vote:
 

Hi all

I'm trying to create a new Episerver Market using the IMarketService.CreateMarket method. On the MarketImpl, I'm adding the Country "Netherlands".

Looking in the Country table, this looks like the correct name, but when I create the Market, I get the exception below.

I have done a bid of debugging. It looks as if Episerver tries to add the Country to the udttCountryCode user defined table before calling the stored procedure to create the Market. This table is defined like this:

CREATE TYPE [dbo].[udttCountryCode] AS TABLE(

[CountryCode] [nvarchar](8) NULL

)

But "Netherlands" is a little more than 8 characters. This looks like a bug in Episerver? Can somebody (Quan Mai or Son Do) create this bug, or should I create a support ticked for this?

Exception:

SqlException (0x80131904): String or binary data would be truncated.
The data for table-valued parameter "@CountryCodes" doesn't conform to the table type of the parameter. SQL Server error is: 8152, state: 10
The statement has been terminated.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +3277336
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +345
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +5002
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption) +492
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +3152
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +704
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +512
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +406
   EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute(Func`1 method) +925
   Mediachase.Data.Provider.SqlDataProvider.ExecuteNonExec(DataCommand command) +395
   SolarB2bEpiserver.Core.Commerce.SqlDataProvider.NcSqlDataProvider.ExecuteNonExec(DataCommand command) in D:\CXP\AOL\Repos\CXP\SolarB2bEpiserver\SolarB2bEpiserver.Core.Commerce\SqlDataProvider\NcSqlDataProvider.cs:12
   Mediachase.Commerce.Markets.Database.MarketServiceDatabase.ModifyMarket(IMarket market, Boolean isUpdate) +2083
   Mediachase.Commerce.Markets.Database.MarketServiceCache.CreateMarket(IMarket market) +19
   SolarB2bEpiserver.Web.Site.Infrastructure.InitializationModules.MarketInitialization.CheckOrCreateMarked(IList`1 markets, Catalog catalog) in D:\CXP\AOL\Repos\CXP\SolarB2bEpiserver\SolarB2bEpiserver\Infrastructure\InitializationModules\MarketInitialization.cs:43
   SolarB2bEpiserver.Web.Site.Infrastructure.InitializationModules.MarketInitialization.Initialize(InitializationEngine context) in D:\CXP\AOL\Repos\CXP\SolarB2bEpiserver\SolarB2bEpiserver\Infrastructure\InitializationModules\MarketInitialization.cs:33
   EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key) +56
   EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context) +123
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +425

#176982
Mar 31, 2017 14:08
Vote:
 

Hi,

No, it's not a bug, it's feature. When you add the countries to a market, it should be the ISO country code. For Netherlands it should be NLD. You can take a look at Country table to see all country codes available.

Regards,

/Q

#176985
Mar 31, 2017 14:45
Vote:
 

Hi Quan

Oh, well I added "Denmark" as country code, and that gave me no erros. That was why I thought it was a bug.

I will change my code to add the correct values. Perhaps you could consider to add a check for the correct values?

Regards

Anders

#176987
Mar 31, 2017 14:51
Vote:
 

Yes, we can consider that - however no promises at this point :) 

#176990
Mar 31, 2017 14:54
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.