 |
|
ขอรบกวนหน่อยครับท่าน คือผมหางหายจากการเขียนโปรแกรมไปนาน สอบถามเรื่อง combobox |
|
 |
|
|
 |
 |
|
ตรงนะครับ
พี่วินหรือท่านผู้รู้ ท่านอื่น พอมีวิธีอื่นไหมครับ เวลาเลือกชือใน combobox แล้วให้โชว id ใน textbox
ขอบคุณมากครับพี่วินและท่านอื่นที่ช่วยต่อบด้วยนะครับ
|
ประวัติการแก้ไข 2012-09-25 11:38:24 2012-09-25 11:44:51
 |
 |
 |
 |
Date :
2012-09-25 11:34:13 |
By :
Testprogram |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
private void cmbProName_SelectedIndexChanged_1(object sender, EventArgs e)
{
string constr = Properties.Settings.Default.DatabaseCarserviceConnectionString;
OleDbConnection conn = new OleDbConnection(constr);
DataTable dt = new DataTable();
string str = "SELECT [Pro_ID] ,[Pro_Name_Model] ,[Price] FROM Product where Pro_Name_Model = '" + cmbProName.Text + "' ";
OleDbCommand cmd = new OleDbCommand(str, conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(str, conn);
adapter.Fill(dt);
if (dt.Rows.Count > 0)
{
this.txtProID.Text = (string)dt.Rows[0]["Pro_ID"];
this.txtPrice.Text = (string)dt.Rows[0]["Price"].ToString();
}
}
Code C# นะครับ แปลงดูเอา
|
 |
 |
 |
 |
Date :
2012-09-25 22:22:14 |
By :
Pete |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|