The connection string had to encryted to work. The team working on the project used base64encode.org to encode the string.
Invalid Character in Base-64 String” using ASP.NET
-
09-10-2022 - |
Question
I have a Sql Server 2008 R2 connection string that looks like
<add name="DBConnectionString"
providerName="System.Data.SqlClient"
connectionString="Data Source=AYZ;Initial Catalog=AYZ;User ID=AYZ;Password=AYZ;"/>
When trying to create a new instance of SQLDatabase using EnterpriseLibrary.Data I get the above error.
connString =ConnectionStrings.ConnectionStrings["ConnectionString"];
Database objDB = new SqlDatabase(connString);
The detailed exception is as follows :
System.FormatException was unhandled by user code
Message=Invalid character in a Base-64 string.
Source=mscorlib
StackTrace:
at System.Convert.FromBase64String(String s)
at Microsoft.Practices.EnterpriseLibrary.Data.Database.DecryptConnectionString(String strEncyptConStr)
at Microsoft.Practices.EnterpriseLibrary.Data.Database..ctor(String connectionString, DbProviderFactory dbProviderFactory)
at Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase..ctor(String connectionString)
at Syntel.GRC.DAL.CommonDAL..ctor() in D:\Vrushal\Projects\Right Price\Syntel.GRC\Syntel.GRC\Syntel.GRC.DAL\CommonDAL.cs:line 31
at Syntel.GRC.BLL.CommonBLL..ctor() in D:\Vrushal\Projects\Right Price\Syntel.GRC\Syntel.GRC\Syntel.GRC.BLL\CommonBLL.cs:line 14
at Global.Application_Error(Object sender, EventArgs e) in d:\Vrushal\Projects\Right Price\Syntel.GRC\Syntel.GRC\Syntel.GRC.WEB\App_Code\Global.asax.cs:line 60
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.HttpApplication.RaiseOnError()
InnerException:
Please help me with a solution.
Thanks.
Solution 2
OTHER TIPS
You're missing a "
at the end of the connection string property. It should be:
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=ServerName\InstanceName;Initial Catalog=DatabaseName;"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow