DataTable dt = GetDatafromDatabase(); //===== returns a DataTable
string SQLT = "SELECT * FROM tbl_TempReport";
string colname;
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
SqlCommand cmdT = new SqlCommand(SQLT, cn);
SqlDataReader rt = cmdT.ExecuteReader();
while (rt.Read())
{
// For each row, print the values of each column.
foreach (DataColumn column in dt.Columns)
{
foreach (DataRow row in dt.Rows)
{
colname = column.ColumnName.ToString();
if (colname == "ID")
{
// break;
rt.NextResult();
}
else
{
rt.Read();
//if (rt["code"].ToString() == colname)
//{
//insert into tbl_TempReport to match the appropriate column
string SQLP = "UPDATE tbl_TemReport SET VALUEP = @VALUEP WHERE code = @code";
SqlCommand cmdp = new SqlCommand(SQLP, cn);
cmdp.Parameters.AddWithValue("@VALUEP", SqlDbType.Int).Value = row[column].ToString();
cmdp.Parameters.AddWithValue("@code", SqlDbType.NVarChar).Value = rt["code"].ToString();
cmdp.ExecuteNonQuery();
//}
//ListBox1.Items.Add(row[column.ColumnName].ToString());
}
//======
}
}
}
i will appreciate your help as the is module in my project due to be submitted on Monday.
Thank you and God blessing