0

我在winform中工作一个字典项目。我有一个文本框,我在其中输入我的文本。每当我输入任何文本时,我都会在word = my_entered_text的位置显示单词及其含义。我试过这样

private void textBox1_TextChanged(object sender, EventArgs e)
    {

        string word = textBox1.Text;

        //connect to database
        SqlCeConnection con = new SqlCeConnection(@"Data Source=C:\Users\Imon-Bayazid\Documents\new2.sdf");


        using (con)
        {
            con.Open();
            // 2
            // Create new DataAdapter
            using (SqlCeDataAdapter a = new SqlCeDataAdapter(
               "SELECT English FROM Table1 WHERE (English like '" + word + "%')", con))
            {
                // 3
                // Use DataAdapter to fill DataTable
                DataTable t = new DataTable();
                a.Fill(t);
                // 4
                // Render data onto the screen
                dataGridView2.DataSource = t;
            }

            using (SqlCeDataAdapter b = new SqlCeDataAdapter(
                "SELECT Bangla FROM Table1 WHERE (English like '" + word + "%')", con))
            {
                // 3
                // Use DataAdapter to fill DataTable
                DataTable tt = new DataTable();
                b.Fill(tt);
                // 4
                // Render data onto the screen
                dataGridView1.DataSource = tt;

            }
        }
    }

但它在“dataGridView1.DataSource = tt;”行显示“参数无效”异常 我该如何解决这个问题???

4

1 回答 1

0
"SELECT Bangla FROM Table1 WHERE (English like '" + word + "%')"

PS。表 Bangla 中可能不存在“English”列

于 2013-04-29T09:55:16.130 回答