当我从组合框中选择名称时,如何显示 3 个表中的数据。我假设我需要加入有问题的 3 个表,但我不确定语法。
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string constring = ("Data Source=****************");
string Query = "select * from Table1 where Last='" + cbUsers.SelectedItem.ToString() + "' ;";
SqlConnection conDataBase = new SqlConnection(constring);
SqlCommand cmdDataBase = new SqlCommand(Query, conDataBase);
SqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string sFirst = myReader.GetString(2); //From Table1
string sLast = myReader.GetString(1); //From Table1
string sdob = myReader.GetString(3);//From Table2
string scode = myReader.GetString(1);//From Table3
txtFirst.Text = sFirst;
txtdob.Text = sdob;
txtcode.Text = scode;