我正在尝试从访问中获取一个值并将其放入字符串变量或文本框中,我使用的是 MS-Visual Studio 2012 和 Access 2007
string sql = "SELECT [Time Checked-In] FROM HotelCustomers WHERE [Room Number] =" + textBox1.Text + ";";
string my_Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= c:\\Users\\Acer\\Documents\\HotelCustomersOld.mdb";
OleDbConnection myCon = new OleDbConnection(my_Connection);
myCon.Open();
DataTable dataTable = new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter(sql, my_Connection);
adapter.Fill(dataTable);
string aString = dataTable.Rows[0]["Time Checked-In"].ToString();
textBox1.Text = aString;