How to append two field values in combobox display member in C#

后端 未结 7 633
死守一世寂寞
死守一世寂寞 2020-12-30 02:43

In my table, I have a field of firstname and lastname, now what I want is to set firstname and lastname as displaym

7条回答
  •  时光说笑
    2020-12-30 03:35

    CREATE VIEW [dbo].[get_view] AS SELECT CONCAT(sell_tb.Name,extra_tb.Name,purchase_tb.Name) AS Name FROM sell_tb FULL JOIN extra_tb ON extra_tb.E_ID = sell_tb.E_ID FULL JOIN purchase_tb ON purchase_tb.S_ID = sell_tb.S_ID;

          private void alldata1()
        {
            conn.Open();
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from [get_view]";
            cmd.ExecuteNonQuery();
            DataTable dt = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            sda.Fill(dt);
            comboBox1.DataSource = dt;
            comboBox1.DisplayMember = "Name";
            conn.Close();
        }
    

提交回复
热议问题