CAN WE ASSIGN A PARTICULAR DATASET COLUMN VALUE TO A VARIABLE

Elena Glibart

Total Post:42

Points:296
Posted by  Elena Glibart
C# 
 868  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. lois waisbrooker

    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();

  1. Samuel Fernandes

    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();

            }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!