Converting to a string...

i want to convert a data row value to a string but i get an error

saying System.Data.DataRow cannot be converted to a string, how can i do this without getting an error can i use a CType to convert it




Answer this question

Converting to a string...

  • golfkeelo

    DataTable table;
    DataRow row;

    //Get a DataRow object "row" from your DataTable "table".
    //Then loop over each column and print its value.

    for(int iCol=0; iCol<table.Columns.Count; iCol++)
    {
     Console.WriteLine(row[iCol].ToString());
    }

     

    Note that you cannot do row.ToString(), since that will just print out "System.Data.DataRow".

     

    Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights



  • Paul Ayre

    You can convert anything to string by calling ToString() on it. However, that won't do you any good in case of System.Data.DataRow, all you would get is a type name. If you're trying to get a string with values of all columns in this row, please use simple loop to print them out.



  • stanb

    I believe that what SirajLala posted will work. However, could you post any code snippets that is causing this error


  • CanopenR

    I hate to ask silly question but did that remove the copy and paste feature in the forumns....

  • Alan.328

    The orignal values are of type string and i want to print them after calling my word.range to a word.document

  • WolfTechnologies

    what's the original data types for that particular column/ row

  • Converting to a string...