0
Answer

Null Output

richard lim

richard lim

17y
2.7k
1

Hi guys can anybody tell me why is my 2nd column outputing null can anyone fix it tnx ^_^.

SqlConnection
sqlCN = new SqlConnection();

sqlCN.ConnectionString = strCN;

SqlDataAdapter sqlDADetail = new SqlDataAdapter(strSPDetail, sqlCN);

DataSet sqlDS = new DataSet();

sqlDADetail.SelectCommand.CommandType = CommandType.StoredProcedure;

sqlDADetail.Fill(sqlDS, tblName);

sqlCN.Close();

DataSet TmpDS = new DataSet();

TmpDS.Tables.Add("TmpTable");

int iCol = 0;

int iRow = 0;

 

foreach (DataColumn dc in sqlDS.Tables[0].Columns)

{

strCol = dc.Table.Columns[iCol].ToString();

TmpDS.Tables[0].Columns.Add(strCol);

MessageBox.Show(TmpDS.Tables[0].Columns[iCol].ToString());

foreach (DataRow dr in sqlDS.Tables[0].Rows)

{

strRow = dr.Table.Rows[iRow][iCol].ToString();

TmpDS.Tables[0].Rows.Add(strRow).ToString();

MessageBox.Show(TmpDS.Tables[0].Rows[iRow][iCol].ToString());

iRow++;

}

iRow = 0;

iCol++;

}