2011-06-14 60 views

回答

0

嘗試string row = ds.Tables[0].Rows[0].ToString()

如果你想顯示某種特定問題我建議

DataRow row = ds.Tables[0].Rows[0]; 

string summary = "Field1 = " + row["Field1"] + "; Field2 = "+ row["Field2"]; //etc 

我也問自己,爲什麼我在內存中包含的變量37k行,如果這是實現我所需要的唯一方法。

+0

如果我嘗試檢查的價值在調試模式下行,它只是說System.Data.Datarow,我如何看到實際的內容? – Amrutha 2011-06-14 10:25:18

+0

您可以在調試模式下看到DataSet/DataTable/DataRow的內容 – cusimar9 2011-06-14 10:26:01

+0

我只想查看行內容,是不可能的?說它有10列,我想看看每列的價值,最好的方法是什麼? – Amrutha 2011-06-14 10:30:07

1

你可以嘗試這樣的事:

private String DataRowToString(DataRow row, DataColumnCollection columns) 
{ 
    StringBuilder rowStringBuilder = New StringBuilder(); 
    foreach (DataColumn dc in columns) 
    { 
     dataRowBuilder.AppendFormat("{0} = {1}", dc.ColumnName, row(dc.Ordinal)); 
     dataRowBuilder.AppendLine(); 
    } 

    return dataRowBuilder.ToString(); 
} 

String rowString = ConvertDataRowToString(ds.Tables[0].Rows[0], ds.Tables[0].Columns) 
相關問題