我想做一個C#程序,將通過單擊按鈕從我的ms訪問數據庫中選擇一個隨機數據..錯誤說,從我創建的OleDbDataReader Data type mismatch in criteria expression.
。c# - 從ms訪問數據庫隨機生成數據
這就是我目前實現的目標。將不勝感激。
{
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\miguel\Documents\QuotesGenFunny.accdb;
Persist Security Info=False;";
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "SELECT TOP 1 * FROM Funny ORDER BY Rnd(-10000000*TimeValue(Now())*[Author])";
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
listBox1.Items.Add(reader["Author"].ToString());
}
connection.Close();
}