110,533
社区成员
发帖
与我相关
我的任务
分享
class odb
{
public void Conn()
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\DataBase\MyDB.mdb";
OleDbConnection odcConnection = new OleDbConnection(strConn);
odcConnection.Open();
OleDbCommand odCommand = odcConnection.CreateCommand();
odCommand.CommandText = "select * from guojia";
OleDbDataReader odrReader = odCommand.ExecuteReader();
ArrayList Arr = new ArrayList();
while (odrReader.Read())
{
Arr.Add(odrReader["1"].ToString());
}
odrReader.Close();
odcConnection.Close();
}
}
//调用
odb db = new odb();
ArrayList arrayList = db.Conn();
class odb
{
public ArrayList Conn()
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\DataBase\MyDB.mdb";
OleDbConnection odcConnection = new OleDbConnection(strConn);
odcConnection.Open();
OleDbCommand odCommand = odcConnection.CreateCommand();
odCommand.CommandText = "select * from guojia";
OleDbDataReader odrReader = odCommand.ExecuteReader();
ArrayList Arr = new ArrayList();
while (odrReader.Read())
{
Arr.Add(odrReader["1"].ToString());
}
odrReader.Close();
odcConnection.Close();
return arr;
}
}