|
-
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.
-
November 29th, 2007, 10:38 PM
#2
Re: Bindingsource add row
what is the data source of "horariosBindingSource"?
-
November 29th, 2007, 10:55 PM
#3
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.
-
November 29th, 2007, 10:59 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|