title: How to convert data read from data reader to base64 string and add to datatable?
body: <p>i have binary data stored (data of an image) stored in the database. So basically i want to retrieve that data , convert it into base 64 string and put it into a data table as i will be returning the datatable into a webservice.</p>
  
  <p>The code for retrieving the data from the database is as follows.</p>
  
  <pre><code>public DataTable GetImageDetails(string userName)
  {
      DataTable imageTable = new DataTable();
      imageTable.Columns.Add(new DataColumn("img_storage", typeof(String)));
  
  
      if (dbConnection.State.ToString() == "Closed")
      {
          dbConnection.Open();
      }
  
      string query = "SELECT img_storage FROM Image_table WHERE vehicle_no IN( SELECT vehicle_no FROM User_table  WHERE username='" + userName + "')";
  
      SqlCommand command = new SqlCommand(query, dbConnection);
  
      SqlDataReader reader = command.ExecuteReader();
      if (reader.HasRows)
      {
          while (reader.Read())
          {
              imageTable.Rows.Add(reader["img_storage"]);
          }
      }
  
      reader.Close();
      dbConnection.Close();
      return imageTable;
  } 
  </code></pre>
  
  <p>How can I convert data and add to the data table by editing this code? Please Help me!</p>