Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving dataset values in strings

Status
Not open for further replies.

TiltingCode

Programmer
Apr 10, 2009
61
0
0
US
The below code works.... sort of. I can write the values to the console but what I want to do is store the values in strings. Only one row is returned with two fields.

As you can see I tried this two different ways and both work with the console but I can't get any to be stored in a string without erring out.

Can someone please help?

Code:
 string strSQL = "EXECUTE uspSelectStoredProcedure '" + strDocumentName + "'";

      SqlDataAdapter DataAdapter = new SqlDataAdapter(strSQL, strConnection);
      DataSet RS = new DataSet();

      DataAdapter.Fill(RS);

      System.Data.DataTable datTable = RS.Tables[0];

      DataRow[] rows = datTable.Select("StoredProcedureName Is Not Null");

      Console.WriteLine(rows[0][0]);
      Console.WriteLine(rows[0][1]);

      foreach (DataRow row in datTable.Rows)
      {
        foreach (DataColumn column in datTable.Columns)
        {
          Console.WriteLine(row[column]);
        }
      }
 
Never mind, I finally solved it:
All I had to do was use the Convert.ToString() function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top