CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2002
    Location
    Ibague, Colombia S.A.
    Posts
    54

    Bindingsource add row

    I have a Dataset ( a master and a detail tables), a Bindingsource (Detail Table "Horarios") and a Tableadapter linked to a datagrid.

    When I try to add a row to the table the next error occurs:
    "Objects added to a list of bindingsource be all of the same type"

    Code:
                
    
    private void btnCrear_Click(object sender, EventArgs e)
            {
    
                DataRow NuevoHorarioRow = seguridadDataSetFestivos.Tables["Horarios"].NewRow();
                
                NuevoHorarioRow[0] = cbCuenta.SelectedValue;                     
                NuevoHorarioRow[1] = cbTipo.SelectedIndex;      
                string sHora = cbHora.SelectedIndex.ToString();
    
                foreach (int indCheck in ckDias.CheckedIndices)
                {
                    int j = 2 + indCheck;                       
                    NuevoHorarioRow[j] = System.Convert.ToDateTime(sHora);
                }
                
                try
                {
                     this.horariosBindingSource.Add(NuevoHorarioRow);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR: \n" + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
    .....
    
    Also, I have tried with only the first field (Integer, primary key) and the other null.

    The fields of the table are:
    0: Int
    1: Int
    2 to 9: smalldatetime

    Thanks for any orientation.

  2. #2
    Join Date
    Jul 2003
    Location
    Bali, Indonesia
    Posts
    103

    Re: Bindingsource add row

    what is the data source of "horariosBindingSource"?

  3. #3
    Join Date
    Apr 2002
    Location
    Ibague, Colombia S.A.
    Posts
    54

    Re: Bindingsource add row

    The datasource is "SeguridadDataset" which contains the master table "Cuentas" and "Horarios". In this last is where I need to add a new row.

  4. #4
    Join Date
    Jul 2003
    Location
    Bali, Indonesia
    Posts
    103

    Re: Bindingsource add row

    May be you should try to binding only one tables...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured