2014-01-18 115 views
1
SqlCommand Mysqlcommand = new SqlCommand(); 

if (MyConnection.State == ConnectionState.Closed) 
{ 
    MyConnection.Open(); 
} 

Mysqlcommand.Connection = MyConnection; 
Mysqlcommand.CommandText = MysqlQuery; 
Mysqlcommand.CommandTimeout = 120; 

SqlDataReader MySqlDataReader; 
MySqlDataReader = Mysqlcommand.ExecuteReader(); 

bindingSource4.DataSource = MySqlDataReader; 
gridview.DataSource = bindingSource4; 

我想有在DataGridView作为示例图像:显示倍数表结果

enter image description here

+0

您可以添加更多文本吗?这是模糊的。 – Rob

回答

0

欢迎StackOverflow上,

我会建议你首先在SQL中执行该命令:

SELECT a.Sr, a.[International Tender], a.Total, b.[Domestic Tender], b.Total, 
c.[News Automation],c.Total, d.[News Manual], d.Total 
FROM 
    tableA a 
     inner join 
    tableB b 
     ON a.Sr = b.Sr 
     inner join 
    TableC c 
     ON b.[Domestic Tender] = c.[News Automation] 
      inner join 
    TableD d 
     ON c.[News Automation] = d.[News Manual] 

如果它满足您的期望我可以将它转换为C#代码,将其设置为datagridview来源