INVALID CHARACTER IN BASE-64 STRING” USING ASP.NET

sandy taylor

Total Post:46

Points:324
Posted by  sandy taylor
 1889  View(s)
Ratings:
Rate this:

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.

  1. Maria Susan

    Post:29

    Points:107
    Re: Invalid Character in Base-64 String” using ASP.NET

    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;"/>

  1. Pawan Shukla

    Post:29

    Points:203
    Re: Invalid Character in Base-64 String” using ASP.NET

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!