日期:2014-05-18 浏览次数:21081 次
string dbPath = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)+@"\mdb.mdb"; ADODB.Connection conn = new ADODB.Connection(); string connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+dbPath; string sql = "select * from test where ID=2"; conn.Open(connstr, "", "",-1); ADODB.Recordset rs = new ADODB.Recordset(); rs.Open(sql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1); if (!rs.EOF) { MessageBox.Show(rs.Fields[2].Value.ToString()); } rs.Close(); conn.Close();