string strcmd = "select * from BB";
            string strcn = "Provider=SQLOLEDB;Initial Catalog=test;Data Source=MHRREQ08;User ID=sa;Password=;";
     
            DataTable dt = new DataTable();
            System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter();
            ADODB.Connection strcon = new ADODB.Connection();
            strcon.Open(strcn, null, null, 0);
            ADODB.Recordset rs = new ADODB.Recordset();
            rs.Open(strcmd, strcon, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic, -1);

            da.Fill(dt, rs);

            dataGridView1.DataSource = dt;

            rs.Close();
            strcon.Close();

posted on 2009-02-20 14:26  wn323225  阅读(157)  评论(0)    收藏  举报