Home > DeveloperSection > Forums > Invalid Character in Base-64 String” using ASP.NET
sandy taylor
sandy taylor

Total Post:46

Posted on    December-08-2014 2:20 AM

 ASP.Net Validation 

 2 Reply(s)
 1749  View(s)
Rate this:

I have a Sql Server 2008 R2 connection string that looks like


  <add name="DBConnectionString"


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.



       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()


Please help me with a solution.


Maria Susan

Total Post:29

Posted on    December-08-2014 6:23 AM

You're missing a " at the end of the connection string property. It should be:


<add name="ConnectionStringName"


    connectionString="Data Source=ServerName\InstanceName;Initial Catalog=DatabaseName;"/>

Pawan Shukla
Pawan Shukla

Total Post:29

Posted on    December-08-2014 7:38 AM

The connection string had to encrypt to work. The team working on the project used base64encode.org to encode the string.

Don't want to miss updates? Please click the below button!

Follow MindStick