Home > Net >  Datagridview appeared strange after joining together two tables
Datagridview appeared strange after joining together two tables

Time:11-20

A table structure

B table structure


DATAGRIDVIEW stitching out pretty strange phenomenon after



The few lines below should be in the top tier 3, now went to the below, there are several strange number 3, please help see what reason?


 namespace tools{
Public partial class main program: the Form
{
The public the main program ()
{
InitializeComponent ();
}
String filenameurl=null;

Private OleDbDataAdapter find_do;
Private OleDbDataAdapter find_do1;


Private void b_ok_Click (object sender, EventArgs e)
{
This. D_xs. ColumnHeadersDefaultCellStyle. Alignment=DataGridViewContentAlignment. MiddleCenter;
This. D_xs. ColumnHeadersDefaultCellStyle. Alignment=DataGridViewContentAlignment. MiddleCenter;

String sql_str="SELECT sum (total amount to be) as AA, the sum (orders came pen) as BB sales TAB WHERE the FROM came megabite='famous brand shoe shoe kind of'" +
"UNION ALL SELECT sum (total amount to be) as AA, the sum (orders came pen) as BB sales TAB WHERE the FROM came megabite='fair maiden outfit industry" +
"UNION ALL SELECT sum (total amount to be) as AA, the sum (orders came pen) as BB sales TAB WHERE the FROM came megabite='less women's clothing industry" +
"UNION ALL SELECT sum (total amount to be) as AA, the sum (orders came pen) as BB sales TAB WHERE the FROM came megabite='men's toy industry" +
"UNION ALL SELECT sum (total amount to be) as AA, the sum (orders came pen) as BB sales TAB WHERE the FROM came megabite='sports leisure industry" +
"UNION ALL SELECT sum (total amount to be) as AA, the sum (orders came pen) as BB sales TAB WHERE the FROM came megabite='household life industry";

OleDbConnection conn=new OleDbConnection (" Provider=Microsoft. Jet. The OLEDB. 4.0; The Data Source=Data_tg. MDB ");
OleDbCommand CMD=new OleDbCommand (sql_str, conn);
Conn. The Open ();

Find_do=new OleDbDataAdapter ();
Find_do. SelectCommand=CMD;

D_xs. RowHeadersWidth=150;
The DataTable DataTable=new DataTable ();
Find_do. The Fill (dataTable);

String sql_str1="SELECT sum (summary) value as CC FROM the store brand sales summary WHERE summary megabite='famous brand shoe shoe kind of'" +
"UNION ALL SELECT sum (summary) value as CC FROM the store brand sales summary WHERE summary megabite='fair maiden outfit industry" +
"UNION ALL SELECT sum (summary) value as CC FROM the store brand sales summary WHERE summary megabite='less women's clothing industry" +
"UNION ALL SELECT sum (summary) value as CC FROM the store brand sales summary WHERE summary megabite='men's toy industry" +
"UNION ALL SELECT sum (summary) value as CC FROM the store brand sales summary WHERE summary megabite='sports leisure industry" +
"UNION ALL SELECT sum (summary) value as CC FROM the store brand sales summary WHERE summary megabite='household life industry";
OleDbConnection conn1=new OleDbConnection (" Provider=Microsoft. Jet. The OLEDB. 4.0; The Data Source=Data_tg. MDB ");
OleDbCommand cmd1=new OleDbCommand (sql_str1, conn);
Find_do1=new OleDbDataAdapter ();
Find_do1. SelectCommand=cmd1;
The DataTable dataTable1=new DataTable ();
Find_do1. The Fill (dataTable1);
The dataTable. Merge (dataTable1);

DataRow dataRows.
DataRows=dataTable. NewRow ();
Pute dataRows [0]=dataTable.Com (" the Sum (AA) ", "true");
Pute dataRows [1]=dataTable.Com (" the Sum (BB) ", "true");
Pute dataRows [2]=dataTable.Com (" the Sum (CC) ", "true");
The dataTable. Rows. The Add (dataRows);

Enclosing d_xs. The DataSource=dataTable;

CodePudding user response:

This code to write thin pieces

CodePudding user response:

Just try this stitching method
  •  Tags:  
  • C#
  • Related