1
美好的一天先生!我可以使用阅读器从我的数据库中调用数据,并且在获得数据库中的数据后,当我得到我的预期数据时,它们将显示为一个messageBox。这里是我的示例代码:正确使用阅读器从ms访问数据库获取数据
if (textBox5.Text == "")
{ }
else
{
DialogResult ms = MessageBox.Show("Try Again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
if (ms == DialogResult.OK)
{
textBox5.Clear();
textBox1.Clear();
listBox5.Items.Clear();
textBox3.Clear();
listBox4.Items.Clear();
}
}
while (reader.Read())
{
listBox4.Items.Clear();
if (string.Compare(label1.Text, reader.GetString(0)) == 0)
{
for (int t = 1; t < 11; t++)
{
words.Add(reader.GetString(t));
}
}
words.Shuffle();
listBox4.Items.AddRange(words.ToArray());
}
reader.Close();
coon.Close();
我在这里的问题是,当我将这些代码中,有两个消息框会出现,所以我删除此代码:
textBox5.Clear();
textBox1.Clear();
listBox5.Items.Clear();
textBox3.Clear();
listBox4.Items.Clear();
我要的是我想说明的messageBox一次。你能帮助我吗?
感谢您的回答,先生。 我想我知道程序中的打嗝在哪里。 你给我看了一个很大的提示先生。 它帮助我很多tnx :) –