【发布时间】:2016-02-08 16:16:40
【问题描述】:
我就是这样做的,我得到一个数据类型未匹配,但是 tamp 是一个整数,所以我认为它是别的东西(我还在程序的另一个阶段传递了一个整数来 tamp)。 我是否需要通过另一个 int 传递它?还是我的访问声明有问题?整个代码块在没有额外的 where 参数和 for 循环的情况下工作。
for 循环帮助我按顺序加载它们,这对我正在使用它的操作很重要
for (int i = -100; i < 100; i++)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "select * from Table1 where Status='" + comboBox5.Text + "'AND Tamp='" + i + "'";
command.CommandText = query;
listBox9.Items.Clear();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
listBox9.Items.Add(reader["Description"].ToString());
}
// MessageBox.Show("Data Saved");
connection.Close();
}
catch (Exception ex)
{ MessageBox.Show("error " + ex); }
}
【问题讨论】:
-
这是一部有趣的漫画,但最有可能编写不安全代码的初学者不会知道您想通过漫画的链接告诉他们什么。