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"
Also, I have tried with only the first field (Integer, primary key) and the other null.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);
}
.....
The fields of the table are:
0: Int
1: Int
2 to 9: smalldatetime
Thanks for any orientation.
