【发布时间】:2013-10-15 06:32:36
【问题描述】:
我正在尝试制作一个 C# 程序,该程序将通过单击一个按钮从我的 ms 访问数据库中选择一个随机数据。错误表明 Data type mismatch in criteria expression. 来自我创建的 OleDbDataReader。
这是我目前实现的。答案将不胜感激。
{
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();
}
【问题讨论】:
标签: c# database ms-access-2007 oledb