如何从C#程序中的访问数据库中查看数据库中是否存在数据,以及显示“数据库中存在单词”的消息框。
这是我到目前为止所做的:
private void check_word_exists_Click(object sender, EventArgs e)
{
StopWordsDataSet.StopWordsRow wordsRow = stopWordsDataSet.StopWords.FindByword(query_word.Text);
if (query_word.Text = )
{
Console.WriteLine("Stop word exists");
}
else
{
Console.WriteLine("Stop word doesn't exists");
}
}
答案 0 :(得分:0)
我几乎在那里,但我可以知道如何做到这一点
private void check_word_exists_Click(object sender, EventArgs e)
{
StopWordsDataSet.StopWordsRow wordsRow = stopWordsDataSet.StopWords.FindByword(query_word.Text);
try
{
if (query_word.Text == wordsRow.word)
{
query_word.Text = query_word.Text;
MessageBox.Show("Stop word '"+ query_word.Text + "' exists");
query_word.Text = "";
}
else
{
MessageBox.Show("Stop word doesn't exists");
}
}catch(Exception)
{
query_word.Text = query_word.Text;
MessageBox.Show("Stop word '"+ query_word.Text + "' doesn't exists");
query_word.Text = "";
}
}
谢谢你的帮助