|
-
November 29th, 2007, 07:40 PM
#1
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|