Luke Baker

Luke Baker

  • NA
  • 20
  • 21.5k

update unable to find tablemapping 'table' or datatable 'table'.

Apr 2 2012 1:02 PM
Right so the title of the thread is my error (update unable to find tablemapping 'table' or datatable 'table'.). Basically I am trying to update my view when the data grid view cell is changed. This is attempted with the below code -

Code:
   private void dgvUQ_CellValueChanged(object sender, DataGridViewCellEventArgs e)         {             dc.GainConnection(" ", dgvUQ, "v_stafftrainingDetails");                      }
the gain connection method is called everytime I filter data for example searching first name with text box. However I have added dataAdapter.Update() in this method to see if it will do it but im getting the above error. the gain connection code is below

Code:
public void GainConnection(string command, DataGridView dgv, string strTable)         {             SqlCommand com1 = new SqlCommand();             string conStr;             conStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\NTO.mdf;Integrated Security=True;User Instance=True";            SqlConnection connection = new SqlConnection(conStr);             connection.Open();             com1.Connection = connection;             com1.CommandType = CommandType.Text;             com1.CommandText = command;             DataSet ds = new DataSet();            SqlDataAdapter sqlAdp = new SqlDataAdapter(com1);            sqlAdp.Fill(ds);             sqlAdp.Update(ds);             dgv.DataSource = ds;             dgv.DataMember = strTable;             connection.Close();          }
Thanks for help

Answers (5)