Format of the initialization string does not conform to specification starting at index 0.

Format of the initialization string does not conform to specification starting at index 0

The main cause of this type of error is may be you wrote the connection string inside the quotes like this

Dim myConn As New SqlConnection(“strConnectionString”)

Modify your code like this and try again

Dim myConn As New SqlConnection(strConnectionString)

if you have any suggestions please post reply

About these ads

9 thoughts on “Format of the initialization string does not conform to specification starting at index 0.

  1. thanks so much , just solve d the problem , but actually i was trying to get a connection from another page and it was it unable to convert it implicitly to string until i declared the connection string directly on the required page and off course removed the quotes on the connection strinf

    thanks so much

  2. protected void Page_Load(object sender, EventArgs e)
    {
    string a = ConfigurationManager.ConnectionStrings[“mycon”].ConnectionString;
    SqlConnection c = new SqlConnection();
    c.ConnectionString= a;// THIS LINE IVING ME SAME ERROR
    c.Open();
    SqlCommand cmd = new SqlCommand(“insert into movie[movie],[movie_id])values(@name,@movie_id)”);
    cmd.Parameters.Add(“@movie”, TextBox1.Text);
    cmd.Parameters.Add(“@movie_id”, TextBox2.Text);
    int x = cmd.ExecuteNonQuery();
    Response.Write(“your record has been added”);
    Response.Write(“your insertion has affected:” + x + “no. of records”);
    TextBox1.Text = “”;

  3. getting the same error..

    public class DBConnection
    {
    private static String ConString;
    public IDBManager dbManager = new DBManager();
    public DBConnection()
    {
    ConString = “Data Source=DANGI-HP;Initial Catalog=interchat;Trusted_Connection=False”;
    Configurator objconf = new Configurator();
    System.Reflection.Assembly Asm = System.Reflection.Assembly.GetExecutingAssembly();
    string path = Asm.Location + “.config”;
    String con = objconf.GetConfigData(path, “ConString”);
    String [] arr= con.Split(‘;’);
    //Data Source=GRINFOTE11\SQLEXPRESS;Initial Catalog=interchat;User ID=sa;Password=grinfotech

    //ConString=”Data Source=” + arr[0] + “;Initial Catalog=” +arr[1] +”; User Id=” + arr[2] + “; password=” + arr[3] ;

    ConString = ConfigurationSettings.AppSettings[“ConString”];
    //ConString= ConfigurationManager.ConnectionStrings[“ConString”].ConnectionString;

    }

    • My opinion and a good practice is to store the connection string for your application in a web.config file rather than as a hard coded string in your code

      Try to use the below..

      string strConnString = System.Configuration.ConfigurationManager.ConnectionStrings.Item(“ConString”).ToString();

      If error still persists please feel free to get back. Shall try my level best to help you out.

  4. Menon, my application stores connection string in the registry. Your tip helped me determine that the connection string was enclosed in quotes. Thanks!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s