Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

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

C#
 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
Posted
Updated 28-Dec-15 12:47pm
v6
Comments
Tomas Takac 21-Dec-15 10:42am    
I don't see why not. Are you facing any particular problem?
Golden Basim 21-Dec-15 10:55am    
i can't write code to do that
[no name] 21-Dec-15 11:25am    
Is there any relation in these tables? What have you tried so far add your code here..
Golden Basim 21-Dec-15 12:48pm    
my database have sales table and purchase table , i went to show the two table in data grid veiw sorting by date field
Golden Basim 21-Dec-15 12:57pm    
i updated my Questions to explain what i went

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900