I have uploaded a new website on server, but when i try to run it on web-browser i am getting this error
Format of the initialization string does not conform to specification starting at index 120.
What is the cause of issue & how to resolve it? I didn't got this error before
You need to check your connection string in Web.Config File, basically it is throwing an error because of connection string format is not correct.
SQL Server Connection string formats
Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
Trusted Connection
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Connection to a SQL Server instance
The server/instance name syntax used in the server option is the same for all SQL Server connection strings.
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;
It should resolve your issue.
Or Check if You are updating the database using Code-first(Update-Database
command ) if you have selected the correct project(Entity framework project) in NuGet package manager console or not, if not Nuget may be looking in at the web.config file of that startup or any other project.
In ASP.NET Core
Try checking your Program.cs (.NET Core 6) to have DbConnectionString Syntax as below
builder.Services.AddDbContext<MyDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
I was getting this error, since I forgot to get connection string properly using above command.
Above answer looks good, this error occurs basically because of connection string issue.
If your password contains charatcers like ";'" etc, then add quotes before and after password in connection string, example
<add name="defaultconnection" connectionString="server=local;database=dbanme;user id=userID;password='pass;word'" providerName="System.Data.SqlClient" />
If you are getting this error in ASP.NET Core, you can correct add connection string details in Startup.cs -> ConfigureServices
services.AddDbContext<dbsContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Default")));
Thanks.
If your password contains special characters like ';' then you may need to update your connection string as below
<add name="db" connectionString="server=YourServerName;database=DBName;user id=dbuser;password='pass;word'" providerName="System.Data.SqlClient" />
Note: Above password is enclosed between single quotes (') inside connection string.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly