0
嗨,我试图从VC++
女士Access数据库中检索数据。由于我是VC++
的新手,请帮助我。在VC++窗体中检索MsAccess数据到ComboBox应用程序
这是我写到目前为止的代码。
System::Data::DataSet^ ds=gcnew System::Data::DataSet();
OleDbConnection^con=gcnew OleDbConnection("Provider= Microsoft.ACE.OLEDB.12.0;Data source=dbmc.accdb; Persist Security Info=True");
OleDbCommand^ com =gcnew OleDbCommand();
OleDbDataReader^ myReader;
com->CommandText ="SELECT name FROM Table1";
com->Connection = con;
con->Open();
try
{
myReader=com->ExecuteReader();
while(myReader->Read())
{
String^ vName = myReader->GetString('name');
comboBox1->Items->Add(vName);
myReader->Close();
}
}
catch(Exception^ex)
{
MessageBox::Show(ex->Message);
}
当我运行这个程序,我得到一个错误"Index Out of Bound"
。
超级...它的工作原理就像一个魅力...谢谢... SoupyC – 2013-03-11 16:03:31