from_load
sb.Remove(0, sb.Length)
sb.Append("SELECT LAWSUIT.LawsuitID,CASES.Case_Name,LAWSUIT.PID")
sb.Append(" FROM LAWSUIT,CASES ")
sb.Append(" WHERE (LAWSUIT.CaseID=CASES.CaseID) ")
sb.Append(" AND (LAWSUIT.PID=@PID) ")
Dim sql As String = sb.ToString()
com = New SqlCommand()
With com
.CommandType = CommandType.Text
.CommandText = sql
.Connection = Conn
.Parameters.Add("@PID", SqlDbType.NVarChar).Value = CStr(FormAdd.txtPid.Text)
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable()
dt.Load(dr)
ComboFeature.DataSource = dt
ComboFeature.ValueMember = "LawsuitID"
ComboFeature.DisplayMember = "Case_Name"
Else
ComboFeature.DataSource = Nothing
End If
End With
dr.Close()
ลองทำที่ event SelectedIndexChanged ของ combobox เพื่อจะให้โชวข้อควมที่ textbox แต่ก็ยังไม่ได้ค่ะต้องทำไงคะ
Dim sqll As String = "SELECT LawsuitID FROM BEHAVIORS "
Dim value As String = ComboFeature.SelectedValue.ToString()
If value = sqll Then
sb.Remove(0, sb.Length)
sb.Append("SELECT LawsuitID,DetailsBehavior")
sb.Append(" FROM BEHAVIORS ")
sb.Append(" WHERE (BEHAVIORS.LawsuitID=@value1) ")
Dim sqlv As String = sb.ToString()
com = New SqlCommand()
With com
.CommandType = CommandType.Text
.CommandText = sqlv
.Connection = Conn
.Parameters.Add("@value1", SqlDbType.NVarChar).Value = ComboFeature.SelectedValue
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable()
dt.Load(dr)
txtDetailsBehavior.DataBindings.Add("Text", dt, "DetailsBehavior")
Else
txtDetailsBehavior.Text = ""
End If
End With
dr.Close()
End If
If IsDBNull(DataSet("ตัวที่ทำการ SELECT ค่าออกมาจาก DATABASE นะคับ")) = False Then
TEXTBOX.Text = CStr(DataSet("ตัวที่ทำการ SELECT ค่าออกมาจาก DATABASE นะคับ"))
End If