リストボックスのリストをクリックしてテキストボックスに結果を表示するプロジェクトを作成しました。だから私はリストボックスの値をクリックすると、それは結果を取得する必要があります&データベースからの各列は、私が作成したテキストボックスに収まる必要があります。リストボックスからデータを取得してテキストボックスに表示
私はすでにいくつかのコードを書いていますが、動作しません。私はあなたの助けが必要
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
string s = "select * from recipe";
//SqlCommand cmd = new SqlCommand("select * from recipe where ('" + ListBox1.SelectedItem.ToString() + "')", con);
SqlDataAdapter da = new SqlDataAdapter(s, con);
DataSet ds = new DataSet();
da.Fill(ds);
ing_tx.Text = ListBox1.SelectedValue.ToString();
mx_tx.text = ListBox1.SelectedValue.ToString();
re_tx.text = ListBox1.SelectedValue.ToString();
}
私はつまり、データベース内の3つの列(食材、方法、レシピ)
働いていないでしょうか? – Fruchtzwerg
3つの列またはテーブルがありますか? –
テーブルに3列ある – Vidya