Can we assign a particular dataset column value to a variable

Total Post:42

Points:296
C# 
 1222  View(s)
Ratings:
Rate this:

I have a data set dsProcesses which returns some rows & columns.Now i need to store into a string all the data present in one particular column[Process-ID] of this data set.Can any one of u please suggest in a detailed way.

  1. Post:70

    Points:494
    Re: Can we assign a particular dataset column value to a variable

    Yes you can

    String str =DataSet.Tables[0].Rows[RowIndex]["ColumnNameOrIndex"].ToString();
    String str =DataSet.Tables["TableName"].Rows[0]["ColumnName"].ToString();

      Modified On Apr-07-2018 05:06:02 AM
  1. Post:159

    Points:1117
    Re: Can we assign a particular dataset column value to a variable

    try this...

    DataSet ds = //call your data
            string sMyData= string.Empty;
            foreach(DataRow dr in ds.Tables[0].Rows)
            {
                sMyData =sMyData + "," + dr["ProcessID"].ToString();
            }

      Modified On Apr-07-2018 05:06:28 AM

Answer