Click here to Skip to main content
15,667,355 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I m using C# windows program in Visual Studio 2008 with MS Access at run time I m getting error (Format of the initialization string does not conform to specification starting at index 0.) bellow given the program

public partial class partmaster : Form
       private OdbcConnection con = new OdbcConnection();
       private basecon obj = new basecon(); //basecon is a class file

private void partmaster_Load(object sender, EventArgs e)

 private void grid()
           DataGridViewTextBoxColumn dgvCol = new DataGridViewTextBoxColumn();
           con.ConnectionString = Microsoft.VisualBasic.Strings.Trim(obj.connection().ToString()); // error is showing (Format of the initialization string does not conform to specification starting at index 0.)
           string qry;
Updated 25-Jul-11 19:34pm
Kim Togo 26-Jul-11 1:52am    
What value has obj.connection().ToString() ?
Syed Salman Raza Zaidi 26-Jul-11 1:55am    
Can you share the value of connection string??

1 solution

try changing this line:

private OdbcConnection con = new OdbcConnection();

to this:

private OleDbConnection con = new OleDbConnection();

and you can call your mdb file like this in your app.config:

    <add name="myconn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}App_Data\mydb.mdb" providerName="System.Data.OleDb"/>

hope it helps :)
Share this answer
IndrajitDasgupat 26-Jul-11 2:45am    
public string connection()
string p;
p = Application.StartupPath.ToString() + @"\conn.ini";
string str;
FileStream fs;
str = "";
fs = new FileStream(p, FileMode.Open, FileAccess.Read);// error from here it is going to catch block

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900