{"record":{"id":"49f7cf2162ba17b9","repo":"nopSolutions/nopCommerce","slug":"connectionstringwrongformat","errorCode":null,"errorMessage":"ConnectionStringWrongFormat","messagePattern":"ConnectionStringWrongFormat","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/Presentation/Nop.Web/Controllers/InstallController.cs","lineNumber":217,"sourceCode":"        {\r\n            if (!_fileProvider.FileExists(file))\r\n                continue;\r\n\r\n            if (!_fileProvider.CheckPermissions(file, false, true, true, true))\r\n                ModelState.AddModelError(string.Empty, string.Format(_locService.Value.GetResource(\"ConfigureFilePermissions\"), CurrentOSUser.FullName, file));\r\n        }\r\n\r\n        if (!ModelState.IsValid)\r\n            return View(model);\r\n\r\n        try\r\n        {\r\n            var dataProvider = DataProviderManager.GetDataProvider(model.DataProvider);\r\n\r\n            var connectionString = model.ConnectionStringRaw ? model.ConnectionString : dataProvider.BuildConnectionString(model);\r\n\r\n            if (string.IsNullOrEmpty(connectionString))\r\n                throw new Exception(_locService.Value.GetResource(\"ConnectionStringWrongFormat\"));\r\n\r\n            DataSettingsManager.SaveSettings(new DataConfig\r\n            {\r\n                DataProvider = model.DataProvider,\r\n                ConnectionString = connectionString,\r\n                Collation = model.Collation,\r\n                CharacterSet = model.CharacterSet\r\n            }, _fileProvider);\r\n\r\n            if (model.CreateDatabaseIfNotExists && !await dataProvider.DatabaseExistsAsync())\r\n            {\r\n                try\r\n                {\r\n                    SetProgressMessage(_locService.Value.GetResource(\"Progress.CreateDatabase\"));\r\n                    dataProvider.CreateDatabase();\r\n                }\r\n                catch (Exception ex)\r\n                {\r","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Controllers/InstallController.cs#L199-L235","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)."],"exampleFix":"// before\nvar connectionString = model.ConnectionStringRaw ? model.ConnectionString : dataProvider.BuildConnectionString(model);\nif (string.IsNullOrEmpty(connectionString))\n    throw new Exception(_locService.Value.GetResource(\"ConnectionStringWrongFormat\"));\n\n// example valid SQL Server connection strings:\n// Server=tcp:localhost,1433;Database=nopCommerce;User Id=sa;Password=Your_password123;Encrypt=false\n// Server=localhost;Database=nopCommerce;Integrated Security=true;TrustServerCertificate=true","handlingStrategy":"validation","validationCode":"// Validate the connection string format before saving\nvar connectionString = model.ConnectionStringRaw ? model.ConnectionString : dataProvider.BuildConnectionString(model);\nif (string.IsNullOrWhiteSpace(connectionString))\n{\n    ModelState.AddModelError(\"\", _locService.Value.GetResource(\"ConnectionStringWrongFormat\"));\n    return View(model);\n}","typeGuard":null,"tryCatchPattern":"catch (Exception exc) when (exc.Message == _locService.Value.GetResource(\"ConnectionStringWrongFormat\"))\n{\n    ModelState.AddModelError(\"ConnectionString\", exc.Message);\n    return View(model);\n}","preventionTips":["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."],"tags":["nopcommerce","install","database","connection-string","configuration"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}