title: Programming Practice: Using ExecuteNonQuery with SqlDataAdapter
body: <pre><code> public DataTable UserUpdateTempSettings(int install_id, int install_map_id, string Setting_value,string LogFile)
      {
  
          SqlConnection oConnection = new SqlConnection(sConnectionString);
          DataSet oDataset = new DataSet();
          DataTable oDatatable = new DataTable();
          SqlDataAdapter MyDataAdapter = new SqlDataAdapter();
  
          try
          {
              oConnection.Open();
              cmd = new SqlCommand("SP_HOTDOC_PRINTTEMPLATE_PERMISSION", oConnection);            
              cmd.Parameters.Add(new SqlParameter ("@INSTALL_ID", install_id));
              cmd.Parameters.Add(new SqlParameter ("@INSTALL_MAP_ID", install_map_id));
              cmd.Parameters.Add(new SqlParameter("@SETTING_VALUE", Setting_value));
              if (LogFile != "")
              {
                  cmd.Parameters.Add(new SqlParameter("@LOGFILE",LogFile));
              }
             cmd.CommandType = CommandType.StoredProcedure;
             MyDataAdapter.SelectCommand = cmd;
             cmd.ExecuteNonQuery();                    
             MyDataAdapter.Fill(oDataset);
             oDatatable = oDataset.Tables[0];
             return oDatatable;
          }
          catch (Exception ex)
          {
              Utils.ShowError(ex.Message);
              return oDatatable;
          }
          finally
          {
              if ((oConnection.State != ConnectionState.Closed) || (oConnection.State != ConnectionState.Broken))
              {
                  oConnection.Close();
              }
  
              oDataset = null;
              oDatatable = null;
              oConnection.Dispose();
              oConnection = null;
          }
      }
  </code></pre>
  
  <p>I have used <code>ExecuteNonQuery</code> above.  Normally it's not used with <code>SqlDataAdapter</code>. If I do not use it, I get an error. </p>
  
  <p>Is it bad programming practice to use <code>ExecuteNonQuery</code> with <code>SqlDataAdapter</code>?</p>