添加引用 adodb component然后:ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
string strConn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\data.mdb;";
conn.Open(strConn, "", "", 0);string strSQL = "SELECT * FROM Table1";
ADODB.RecordsetClass rst = new ADODB.RecordsetClass();
rst.Open(strSQL, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0);
.....

解决方案 »

  1.   

    我用的是SQL  2000数据库,请问连接字符串strConn怎样写?急...
      

  2.   

    http://dev.csdn.net/develop/article/17/17850.shtm
      

  3.   

    用"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;User Id=;Password=;"不行,请帮忙看一下该连接字符串有无问题?
      

  4.   

    "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;User Id=;Password=;"User Id= sa;
      

  5.   

    添加引用 adodb component然后:ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
    string strConn = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;User Id=sa;Password=;"
    //User id 是你SQL Server用户
    //Password 是这个用户的密码
    string strSQL = "SELECT * FROM Table1";
    ADODB.RecordsetClass rst = new ADODB.RecordsetClass();
    rst.Open(strSQL, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0);
    .....