I want to display table data in mention formats.
Real Time CEMS Generation Data |
Parameters |
CO2 |
NO |
SO2 |
CO |
PM |
Flow |
UoM |
% |
ppm |
ppm |
ppm |
mg/Nm |
m/s |
UNIT#1 |
13.44 |
355.26 |
1007.85 |
0 |
16 |
15.75 |
UNIT#2 |
0 |
5.72 |
34.46 |
0 |
29 |
0 |
CREATE TABLE [dbo].[unit_one] (
[Id] INT NOT NULL,
[CO2] NCHAR (10) NULL,
[NO] NCHAR (10) NULL,
[SO2] NCHAR (10) NULL,
[CO] NCHAR (10) NULL,
[PM] NCHAR (10) NULL,
[FLOW] NCHAR (10) NULL,
CONSTRAINT [PK_unit_one] PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE TABLE [dbo].[unit_two] (
[Id] INT NOT NULL,
[CO2] NCHAR (10) NULL,
[NO] NCHAR (10) NULL,
[SO2] NCHAR (10) NULL,
[CO] NCHAR (10) NULL,
[PM] NCHAR (10) NULL,
[FLOW] NCHAR (10) NULL,
CONSTRAINT [PK_unit_two] PRIMARY KEY CLUSTERED ([Id] ASC)
);
namespace ReadTxtFile
{
public partial class dsply : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
//string sql = "SELECT f.CO2, f.NO,f.SO2,f.CO,f.PM,f.PM,f.FLOW FROM unit_two INNER JOIN unit_one f ON unit_two.Id=unit_two.Id";
string sql = "select a.CO2 one_co2,a.NO one_no,a.SO2 one_so2,a.CO one_co,a.PM one_pm,a.FLOW one_flow, b.CO2 b_co2,b.NO b_no,b.SO2 b_so2,b.CO b_co,b.PM b_pm,b.FLOW b_flow from unit_one a,unit_two b where a.id=b.id and a.id='137'";
GridView1.DataSource = this.GetData(sql);
GridView1.DataBind();
}
}
private DataTable GetData(string sql)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(sql))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
cmd.Connection = con;
DataTable dt = new DataTable();
sda.Fill(dt);
return dt;
}
}
}
}
}
}