D
David
I am using SQL Server 2005. I have a form with a grid on it. I have this
code in place:
String strFilter = String.Format("Line={0} AND
Time='{12}/{22}/{34} {42}:{52}'",
m_cd.m_iLine,
m_cd.m_dt.Month, m_cd.m_dt.Day,
m_cd.m_dt.Year,
m_cd.m_dt.Hour, m_cd.m_dt.Minute);
DataRow[] rows =
callerIDTemplateDataSet.Callers.Select(strFilter);
if (rows.Length == 0)
callerIDTemplateDataSet.Callers.AddCallersRow(m_cd.m_iLine,
m_cd.m_strName, m_cd.m_strPhone, m_cd.m_dt, m_cd.m_iDuration, m_cd.m_iRings,
strFirstName, strLastName, strAddress, strCity, strState, strZip, "",
m_cd.m_strIO == "I");
else if (rows.Length == 1)
{
DataRow row = rows[0];
row.BeginEdit();
row["Duration"] = m_cd.m_iDuration;
row["Rings"] = m_cd.m_iRings;
row.AcceptChanges();
}
this.callersTableAdapter.Update(callerIDTemplateDataSet.Callers);
A new row is correctly added to the database. The row shows up in the grid
and it is persisted. However, if row.Length is 1 and update is needed. The
grid shows the update but the data is not persisted to the database. Does
anyone know why this would be? The callerIDTemplateDataSet and
callersTableAdapter were created simply by dropping the grid onto the form.
code in place:
String strFilter = String.Format("Line={0} AND
Time='{12}/{22}/{34} {42}:{52}'",
m_cd.m_iLine,
m_cd.m_dt.Month, m_cd.m_dt.Day,
m_cd.m_dt.Year,
m_cd.m_dt.Hour, m_cd.m_dt.Minute);
DataRow[] rows =
callerIDTemplateDataSet.Callers.Select(strFilter);
if (rows.Length == 0)
callerIDTemplateDataSet.Callers.AddCallersRow(m_cd.m_iLine,
m_cd.m_strName, m_cd.m_strPhone, m_cd.m_dt, m_cd.m_iDuration, m_cd.m_iRings,
strFirstName, strLastName, strAddress, strCity, strState, strZip, "",
m_cd.m_strIO == "I");
else if (rows.Length == 1)
{
DataRow row = rows[0];
row.BeginEdit();
row["Duration"] = m_cd.m_iDuration;
row["Rings"] = m_cd.m_iRings;
row.AcceptChanges();
}
this.callersTableAdapter.Update(callerIDTemplateDataSet.Callers);
A new row is correctly added to the database. The row shows up in the grid
and it is persisted. However, if row.Length is 1 and update is needed. The
grid shows the update but the data is not persisted to the database. Does
anyone know why this would be? The callerIDTemplateDataSet and
callersTableAdapter were created simply by dropping the grid onto the form.