我在C# - Visual Studio 2008中的SQLite中执行此查询时遇到了一些问题。我有2个组合框,第二个依赖于在第一个中选择的值(即:省 - >有效城市为那个省)。我搜索了论坛,但我还没弄清楚为什么这个特定的查询返回0结果。我正确设置参数吗?任何建议都会受到高度赞赏,因为我是新手。谢谢!
string provName = this.comboProvDest.GetItemText(this.comboDestProv.SelectedItem);
string queryDestCity = "SELECT d_city FROM Cities WHERE id_prov = @provName ";
SQLiteCommand cmCity = new SQLiteCommand(queryDestCity, conn);
cmCity.Parameters.AddWithValue("@provName", provName );
SQLiteDataReader drCity = cmCity.ExecuteReader();
comboDestProv.Items.Add("");
while (drCity.Read())
{
comboDestCity.Items.Add(drCity["d_city"].ToString());
this.comboDestCity.DropDownStyle = ComboBoxStyle.DropDownList;
}
答案 0 :(得分:1)