title: Change DataType of DataGridView
body: <p>I have done a Tool that selects some data from a VFP-Database and inserts everything in a DataGrid. (until here everything works...) At this point I would like to change some values of a specific Column but I get everytime an error, saying that the type is not correct because "decimal" is expected and I am inserting some strings...</p>
  
  <p>I'll explain with an example. There is a column containing the row id, then I have another column containing all user id's and so on. What I need is to change the user id with the user name. (only in my DataGrid, not in the Database) That means, that for example the cell containing user-id "1234" is changed into "John". My problem: at runtime the column containing "1234" is declared as "decimal" so I can not enter any string.</p>
  
  <p>I have tried to use all of theese three commands (one by one, not all together):</p>
  
  <pre><code>1) dataGrid.Columns["hot_kunde"].CellTemplate.ValueType = typeof(string);
  2) dataGrid.Columns["hot_kunde"].ValueType = typeof(string);
  3) for (int i = 0; i &lt; dataGrid.RowCount; i++)
     {
         dataGrid.Rows[i].Cells[1].ValueType = typeof(String);
         dataGrid.Rows[i].Cells[1].Value = "test";
     }
  </code></pre>
  
  <p>When I use a MessageBox to show the new changed type, it throws "System.String". Alltough it fires an exception (as said before "expecting decimal") when trying to change the value with a string. (for example "test")</p>
  
  <p>Am I missing something??</p>
  
  <p>Thank you for any reply</p>
  
  <hr>
  
  <h2>EDIT:</h2>
  
  <p>Ok, here is my actual code:</p>
  
  <pre><code>public void SqlQuery(String SQL)
      {
          OleDbConnection conn = new OleDbConnection();
          conn.ConnectionString = "Provider=VFPOLEDB;" +
                                  "Data Source=" + Properties.Settings.Default.DBCcontainer + "\\drive.dbc;" +
                                  "Collating Sequence=machine;" +
                                  "Password=;" +
                                  "Mode=Share Deny Write;";
          conn.Open();
  
          OleDbCommand cmd = new OleDbCommand(SQL, conn);
  
          try
          {
              OleDbDataAdapter da = new OleDbDataAdapter(cmd);
              DataTable DTable = new DataTable();
              da.Fill(DTable);
  
              dataGrid.DataSource = DTable;
              conn.Dispose();
              conn.Close();
  
              dataGrid.Columns["hot_kunde"].CellTemplate.ValueType = typeof(string);
              //dataGrid.Columns["hot_kunde"].ValueType = typeof(string);
              for (int i = 0; i &lt; dataGrid.RowCount; i++)
              {
                  //MessageBox.Show(dataGrid.Rows[i].Cells["hot_kunde"].ValueType.ToString());
                  //dataGrid.Rows[i].Cells[1].ValueType = typeof(String);
                  dataGrid.Rows[i].Cells[1].Value = "test";
              }
          }
          catch (OleDbException e)
          {
              MessageBox.Show(e.Message + "\r\n------------------------------------------------------------\r\n\r\n" + e.Source, "OleDbException", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
      }
  </code></pre>
  
  <p>And this is the SQL-String I'm passing to the function:</p>
  
  <pre><code>SqlQuery("SELECT hot_erldat, hot_kunde, hot_bez, hot_text, hot_losung FROM hotges.dbf WHERE UPPER(SUBSTR(hot_bez, 1, " + sup.Length + ")) = '" + sup + "'");
  </code></pre>
  
  <p>Well, here you can't see it, but "hot_kunde" is the user-id and it is defined as decimal in the database but I don't need the user-id, instead I need the name. How can I do this operation?</p>