如何在Datagridview中显示更多表C# [英] How I Can Show More Table In Datagridview C#

查看:91
本文介绍了如何在Datagridview中显示更多表C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我可以使用c#和mysql按日期排序在一个datagridview中显示两个或更多表吗?



for ex:

---------------------------------- -----------------------

| table1.salesNo | table1.salesMoney | table1.date1 |

-------------------------------------- -------------------

| table2.salesNo | table2.salesMoney | table2.date2 |

-------------------------------------- -------------------

| table2.salesNo | table2.salesMoney | table2.date3 |

-------------------------------------- -------------------

| table1.salesNo | table1.salesMoney | table1.date4 |

-------------------------------------- -------------------

| table1.salesNo | table1.salesMoney | table1.date5 |

-------------------------------------- -------------------



i使用此代码但没有数据出现





can i show two table or more in one datagridview using c# and mysql sorting by date ?

for ex:
---------------------------------------------------------
| table1.salesNo | table1.salesMoney | table1.date1 |
---------------------------------------------------------
| table2.salesNo | table2.salesMoney | table2.date2 |
---------------------------------------------------------
| table2.salesNo | table2.salesMoney | table2.date3 |
---------------------------------------------------------
| table1.salesNo | table1.salesMoney | table1.date4 |
---------------------------------------------------------
| table1.salesNo | table1.salesMoney | table1.date5 |
---------------------------------------------------------

i used this code but no data appear

 private MySqlDataAdapter salesinvoices, purchasesinvoices;
        private DataSet jedataset;
private void button2_Click(object sender, EventArgs e)
      {
          const string SELECT_salesinvoices = "SELECT * FROM sales_invoices";
          const string SELECT_purchasesinvoices = "SELECT * FROM purchase_invoices";



          // Compose the connection string.
          string connect_string = Publics.je_Coonn;

          // Create a DataAdapter to load the Addresses table.
          salesinvoices = new MySqlDataAdapter(SELECT_salesinvoices,
              connect_string);

          // Create a DataAdapter to load the Addresses table.
          purchasesinvoices = new MySqlDataAdapter(SELECT_purchasesinvoices,
              connect_string);

          // Create and fill the DataSet.
          jedataset = new DataSet("je_coronasalesdbDataSet");
          salesinvoices.Fill(jedataset, "sales_invoices");
          purchasesinvoices.Fill(jedataset, "purchase_invoices");

          // Bind the DataGrid to the DataSet.
          dataGridView1.DataSource = jedataset;
      }









谢谢





thanks

推荐答案

你用mySQL标记了你的问题。



你可以将这两个表合并为一个联盟。



http://dev.mysql.com/doc /refman/5.7/en/union.html [ ^ ]
You marked your question with mySQL.

You can combine the two tables as a union.

http://dev.mysql.com/doc/refman/5.7/en/union.html[^]


这篇关于如何在Datagridview中显示更多表C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆