nopSolutions/nopCommerce · critical · Exception
ConnectionStringWrongFormat
Error message
ConnectionStringWrongFormat
What it means
Thrown during installation when the resolved connection string is null or empty. The installer either uses the user-supplied raw connection string or builds one via dataProvider.BuildConnectionString(model); if the result is empty, nopCommerce cannot proceed to save DB settings.
Source
Thrown at src/Presentation/Nop.Web/Controllers/InstallController.cs:217
{
if (!_fileProvider.FileExists(file))
continue;
if (!_fileProvider.CheckPermissions(file, false, true, true, true))
ModelState.AddModelError(string.Empty, string.Format(_locService.Value.GetResource("ConfigureFilePermissions"), CurrentOSUser.FullName, file));
}
if (!ModelState.IsValid)
return View(model);
try
{
var dataProvider = DataProviderManager.GetDataProvider(model.DataProvider);
var connectionString = model.ConnectionStringRaw ? model.ConnectionString : dataProvider.BuildConnectionString(model);
if (string.IsNullOrEmpty(connectionString))
throw new Exception(_locService.Value.GetResource("ConnectionStringWrongFormat"));
DataSettingsManager.SaveSettings(new DataConfig
{
DataProvider = model.DataProvider,
ConnectionString = connectionString,
Collation = model.Collation,
CharacterSet = model.CharacterSet
}, _fileProvider);
if (model.CreateDatabaseIfNotExists && !await dataProvider.DatabaseExistsAsync())
{
try
{
SetProgressMessage(_locService.Value.GetResource("Progress.CreateDatabase"));
dataProvider.CreateDatabase();
}
catch (Exception ex)
{
View on GitHub (pinned to 64bdf2ff08)
Solutions
- Provide a valid connection string. For raw mode use the provider-correct format (SQL Server: 'Server=...;Database=...;User Id=...;Password=...;Trusted_Connection=True;').
- For non-raw mode, fill all required fields (Database server, Database name, credentials) so BuildConnectionString succeeds.
- Verify the selected DataProvider matches the connection string format (SQL Server vs MySQL vs PostgreSQL).
Example fix
// before
var connectionString = model.ConnectionStringRaw ? model.ConnectionString : dataProvider.BuildConnectionString(model);
if (string.IsNullOrEmpty(connectionString))
throw new Exception(_locService.Value.GetResource("ConnectionStringWrongFormat"));
// example valid SQL Server connection strings:
// Server=tcp:localhost,1433;Database=nopCommerce;User Id=sa;Password=Your_password123;Encrypt=false
// Server=localhost;Database=nopCommerce;Integrated Security=true;TrustServerCertificate=true Defensive patterns
Strategy: validation
Validate before calling
// Validate the connection string format before saving
var connectionString = model.ConnectionStringRaw ? model.ConnectionString : dataProvider.BuildConnectionString(model);
if (string.IsNullOrWhiteSpace(connectionString))
{
ModelState.AddModelError("", _locService.Value.GetResource("ConnectionStringWrongFormat"));
return View(model);
} Try / catch
catch (Exception exc) when (exc.Message == _locService.Value.GetResource("ConnectionStringWrongFormat"))
{
ModelState.AddModelError("ConnectionString", exc.Message);
return View(model);
} Prevention
- Test the connection string with a standalone client (SSMS, mysql, psql) before pasting it into the installer.
- Match the DataProvider selection to the connection string syntax.
- Fill all non-raw form fields so BuildConnectionString produces a valid string.
When it happens
Trigger: User submits the install form (InstallController line ~217) with an empty/malformed connection string (raw mode) or form fields that BuildConnectionString cannot turn into a valid string (e.g. missing server/database in non-raw mode).
Common situations: ConnectionStringRaw=true but the field left blank; required DB fields (Server, Database, Username, Password) omitted so BuildConnectionString returns empty; a custom data provider's BuildConnectionString has a bug; copy-paste introduced whitespace/hidden characters.
Related errors
- Data provider supports connection only with login and passwo
- Data provider supports connection only with login and passwo
- DatabaseCreationError
- DatabaseNotExists
- Unable to connect to the new database. Please try one more t
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/49f7cf2162ba17b9.
Report an issue: GitHub.