刚学做C#2005中Access数据库的连接,最后到了要"浏览"选择数据源的时候,却出现了一个"ConnectionString"要我填,我填
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库路径
点OK的时候提示
Format of the initilization string does not conform to specification starting at index 0
是怎么回事啊?
我还是学生啊,麻烦高手们帮我解决一下啊,太谢谢了

解决方案 »

  1.   

    如果数据库未设保护,可以这样:
    Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\Northwind.mdb;User ID=Admin;Password=; 如果设了保护:
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\Northwind.mdb;Jet OLEDB:System Database=d:\NorthwindSystem.mdw;User ID=*****;Password=*****;
      

  2.   

    不是连接字符的问题,按照你说的字符串我试过了,说是测试成功,可是就算不填还是会提示测试成功,但是点OK就会提示
    Format of the initilization string does not conform to specification starting at index 0
    晕,我觉得这不是我的操作上的错误,因为同样的,我在同学的电脑上操作也是可以的,但是在我电脑上操作就又问题了,是不是因为我电脑差什么组件没有安装啊?
      

  3.   

    这个问题以前也曾经出现过,当时是因为连接字符串的问题...
    我想原因可能不只是"Format of the initilization string does not conform to specification starting at index 0",可能会有别的什么异常什么的...这样吧,楼主自己用代码写一个连接数据库的测试程序,看是否能通过,用try..catch捕获一下..我觉得可能是什么版本过低的问题....
      

  4.   

    我的意思是说,不要用组件,自己动手写下代码:大致应该如下,比如说我想通过单击一个按钮,把数据库中的数据显示在界面的DataGridView里://在Button的click事件下:OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据库路径");
    try
    {
       OleDbDataAdapter sda=new OleDbDataAdapter ("select * from 表名",con);
       DataSet ds=new DataSet();
       sda.Fill(ds,"yourTable");
       this.DataGridView1.datasource=ds.Tables["yourTable"];
    }
    catch(OleDbException ex)
    {
        MessageBox.show(ex.Message);
    }
    catch(Exception ex)
    {
        MessageBox.show(ex.Message);
    }你这样测试下,看会抛出什么异常来....