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='{1:D2}/{2:D2}/{3:D4} {4:D2}:{5:D2}'",
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.

Re: No update happening by Miha

Miha
Wed Mar 12 12:40:14 CDT 2008

This is a classic.
Instead of AcceptChanges you should call EndEdit();
The former signals that rows isn't modified...
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"David" <david@simmonds.ca> wrote in message
news:17384F02-E776-4A3C-9078-127D233D50EB@microsoft.com...
>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='{1:D2}/{2:D2}/{3:D4} {4:D2}:{5:D2}'",
> 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.
>


Re: No update happening by David

David
Wed Mar 12 20:07:03 CDT 2008

Changing the code to use EndEdit results in the following exception being
thrown:

Concurrency violation: the UpdateCommand affected 0 of the expected 1
records.

So, that is not the solution.

"Miha Markic" <miha at rthand com> wrote in message
news:uZ95vgGhIHA.4164@TK2MSFTNGP05.phx.gbl...
> This is a classic.
> Instead of AcceptChanges you should call EndEdit();
> The former signals that rows isn't modified...
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "David" <david@simmonds.ca> wrote in message
> news:17384F02-E776-4A3C-9078-127D233D50EB@microsoft.com...
>>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='{1:D2}/{2:D2}/{3:D4} {4:D2}:{5:D2}'",
>> 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.
>>
>
>


Re: No update happening by David

David
Wed Mar 12 20:07:29 CDT 2008

Changing the code to use EndEdit results in the following exception being
thrown:

Concurrency violation: the UpdateCommand affected 0 of the expected 1
records.

So, that is not the solution.

"Miha Markic" <miha at rthand com> wrote in message
news:uZ95vgGhIHA.4164@TK2MSFTNGP05.phx.gbl...
> This is a classic.
> Instead of AcceptChanges you should call EndEdit();
> The former signals that rows isn't modified...
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "David" <david@simmonds.ca> wrote in message
> news:17384F02-E776-4A3C-9078-127D233D50EB@microsoft.com...
>>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='{1:D2}/{2:D2}/{3:D4} {4:D2}:{5:D2}'",
>> 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.
>>
>
>


Re: No update happening by Miha

Miha
Thu Mar 13 03:17:13 CDT 2008

"David" <david@simmonds.ca> wrote in message
news:8C0A657C-17E1-4FBB-BE0B-09446A3C866E@microsoft.com...
> Changing the code to use EndEdit results in the following exception being
> thrown:
>
> Concurrency violation: the UpdateCommand affected 0 of the expected 1
> records.
>
> So, that is not the solution.

On the contrary, that is the solution for your first problem. Now you are
bumping to your second problem - update command not being correct.
Check how it is coded.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/


Re: No update happening by David

David
Thu Mar 13 09:55:10 CDT 2008

The update command was created by the IDE. I did not manually change it. It
should be correct, right?

"Miha Markic" <miha at rthand com> wrote in message
news:%23swW1KOhIHA.1408@TK2MSFTNGP03.phx.gbl...
> "David" <david@simmonds.ca> wrote in message
> news:8C0A657C-17E1-4FBB-BE0B-09446A3C866E@microsoft.com...
>> Changing the code to use EndEdit results in the following exception being
>> thrown:
>>
>> Concurrency violation: the UpdateCommand affected 0 of the expected 1
>> records.
>>
>> So, that is not the solution.
>
> On the contrary, that is the solution for your first problem. Now you are
> bumping to your second problem - update command not being correct.
> Check how it is coded.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
>


Re: No update happening by Miha

Miha
Thu Mar 13 10:09:51 CDT 2008

Not necessarily - check it out.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"David" <david@simmonds.ca> wrote in message
news:DAA0C279-C2A0-446D-B8D3-6AA50EDF598E@microsoft.com...
> The update command was created by the IDE. I did not manually change it.
> It should be correct, right?
>
> "Miha Markic" <miha at rthand com> wrote in message
> news:%23swW1KOhIHA.1408@TK2MSFTNGP03.phx.gbl...
>> "David" <david@simmonds.ca> wrote in message
>> news:8C0A657C-17E1-4FBB-BE0B-09446A3C866E@microsoft.com...
>>> Changing the code to use EndEdit results in the following exception
>>> being thrown:
>>>
>>> Concurrency violation: the UpdateCommand affected 0 of the expected 1
>>> records.
>>>
>>> So, that is not the solution.
>>
>> On the contrary, that is the solution for your first problem. Now you are
>> bumping to your second problem - update command not being correct.
>> Check how it is coded.
>>
>> --
>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>
>>
>


Re: No update happening by David

David
Thu Mar 13 10:53:23 CDT 2008

this._adapter.UpdateCommand.CommandText = @"UPDATE [Callers] SET
[Line] = ?, [Name] = ?, [Number] = ?, [Time] = ?, [Duration] = ?, [Rings] =
?, [FirstName] = ?, [LastName] = ?, [Address] = ?, [City] = ?, [State] = ?,
[Zip] = ?, [MapUrl] = ?, [Incoming] = ? WHERE (([ID] = ?) AND ((? = 1 AND
[Line] IS NULL) OR ([Line] = ?)) AND ((? = 1 AND [Name] IS NULL) OR ([Name]
= ?)) AND ((? = 1 AND [Number] IS NULL) OR ([Number] = ?)) AND ((? = 1 AND
[Time] IS NULL) OR ([Time] = ?)) AND ((? = 1 AND [Duration] IS NULL) OR
([Duration] = ?)) AND ((? = 1 AND [Rings] IS NULL) OR ([Rings] = ?)) AND ((?
= 1 AND [Zip] IS NULL) OR ([Zip] = ?)) AND ([Incoming] = ?))";

Nothing magical about that I think.

"Miha Markic" <miha at rthand com> wrote in message
news:%23$kDkxRhIHA.6084@TK2MSFTNGP06.phx.gbl...
> Not necessarily - check it out.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "David" <david@simmonds.ca> wrote in message
> news:DAA0C279-C2A0-446D-B8D3-6AA50EDF598E@microsoft.com...
>> The update command was created by the IDE. I did not manually change it.
>> It should be correct, right?
>>
>> "Miha Markic" <miha at rthand com> wrote in message
>> news:%23swW1KOhIHA.1408@TK2MSFTNGP03.phx.gbl...
>>> "David" <david@simmonds.ca> wrote in message
>>> news:8C0A657C-17E1-4FBB-BE0B-09446A3C866E@microsoft.com...
>>>> Changing the code to use EndEdit results in the following exception
>>>> being thrown:
>>>>
>>>> Concurrency violation: the UpdateCommand affected 0 of the expected 1
>>>> records.
>>>>
>>>> So, that is not the solution.
>>>
>>> On the contrary, that is the solution for your first problem. Now you
>>> are bumping to your second problem - update command not being correct.
>>> Check how it is coded.
>>>
>>> --
>>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>>> RightHand .NET consulting & development www.rthand.com
>>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>>
>>>
>>
>
>


Re: No update happening by KerryMoorman

KerryMoorman
Fri Mar 14 09:31:02 CDT 2008

David,

The last entry in the following thread may apply to your situation:

http://www.thescripts.com/forum/thread433337.html

Kerry Moorman


"David" wrote:

> this._adapter.UpdateCommand.CommandText = @"UPDATE [Callers] SET
> [Line] = ?, [Name] = ?, [Number] = ?, [Time] = ?, [Duration] = ?, [Rings] =
> ?, [FirstName] = ?, [LastName] = ?, [Address] = ?, [City] = ?, [State] = ?,
> [Zip] = ?, [MapUrl] = ?, [Incoming] = ? WHERE (([ID] = ?) AND ((? = 1 AND
> [Line] IS NULL) OR ([Line] = ?)) AND ((? = 1 AND [Name] IS NULL) OR ([Name]
> = ?)) AND ((? = 1 AND [Number] IS NULL) OR ([Number] = ?)) AND ((? = 1 AND
> [Time] IS NULL) OR ([Time] = ?)) AND ((? = 1 AND [Duration] IS NULL) OR
> ([Duration] = ?)) AND ((? = 1 AND [Rings] IS NULL) OR ([Rings] = ?)) AND ((?
> = 1 AND [Zip] IS NULL) OR ([Zip] = ?)) AND ([Incoming] = ?))";
>
> Nothing magical about that I think.
>
> "Miha Markic" <miha at rthand com> wrote in message
> news:%23$kDkxRhIHA.6084@TK2MSFTNGP06.phx.gbl...
> > Not necessarily - check it out.
> >
> > --
> > Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> > RightHand .NET consulting & development www.rthand.com
> > Blog: http://cs.rthand.com/blogs/blog_with_righthand/
> >
> > "David" <david@simmonds.ca> wrote in message
> > news:DAA0C279-C2A0-446D-B8D3-6AA50EDF598E@microsoft.com...
> >> The update command was created by the IDE. I did not manually change it.
> >> It should be correct, right?
> >>
> >> "Miha Markic" <miha at rthand com> wrote in message
> >> news:%23swW1KOhIHA.1408@TK2MSFTNGP03.phx.gbl...
> >>> "David" <david@simmonds.ca> wrote in message
> >>> news:8C0A657C-17E1-4FBB-BE0B-09446A3C866E@microsoft.com...
> >>>> Changing the code to use EndEdit results in the following exception
> >>>> being thrown:
> >>>>
> >>>> Concurrency violation: the UpdateCommand affected 0 of the expected 1
> >>>> records.
> >>>>
> >>>> So, that is not the solution.
> >>>
> >>> On the contrary, that is the solution for your first problem. Now you
> >>> are bumping to your second problem - update command not being correct.
> >>> Check how it is coded.
> >>>
> >>> --
> >>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> >>> RightHand .NET consulting & development www.rthand.com
> >>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
> >>>
> >>>
> >>
> >
> >
>

Re: No update happening by David

David
Fri Mar 14 10:20:55 CDT 2008

I have two DateTime fields (Time and Duration) and they are of type
DateTime, not Date.

"Kerry Moorman" <KerryMoorman@discussions.microsoft.com> wrote in message
news:A4B9029B-E61F-4C4F-AB29-F2D6D1CB9295@microsoft.com...
> David,
>
> The last entry in the following thread may apply to your situation:
>
> http://www.thescripts.com/forum/thread433337.html
>
> Kerry Moorman
>
>
> "David" wrote:
>
>> this._adapter.UpdateCommand.CommandText = @"UPDATE [Callers]
>> SET
>> [Line] = ?, [Name] = ?, [Number] = ?, [Time] = ?, [Duration] = ?, [Rings]
>> =
>> ?, [FirstName] = ?, [LastName] = ?, [Address] = ?, [City] = ?, [State] =
>> ?,
>> [Zip] = ?, [MapUrl] = ?, [Incoming] = ? WHERE (([ID] = ?) AND ((? = 1 AND
>> [Line] IS NULL) OR ([Line] = ?)) AND ((? = 1 AND [Name] IS NULL) OR
>> ([Name]
>> = ?)) AND ((? = 1 AND [Number] IS NULL) OR ([Number] = ?)) AND ((? = 1
>> AND
>> [Time] IS NULL) OR ([Time] = ?)) AND ((? = 1 AND [Duration] IS NULL) OR
>> ([Duration] = ?)) AND ((? = 1 AND [Rings] IS NULL) OR ([Rings] = ?)) AND
>> ((?
>> = 1 AND [Zip] IS NULL) OR ([Zip] = ?)) AND ([Incoming] = ?))";
>>
>> Nothing magical about that I think.
>>
>> "Miha Markic" <miha at rthand com> wrote in message
>> news:%23$kDkxRhIHA.6084@TK2MSFTNGP06.phx.gbl...
>> > Not necessarily - check it out.
>> >
>> > --
>> > Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>> > RightHand .NET consulting & development www.rthand.com
>> > Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>> >
>> > "David" <david@simmonds.ca> wrote in message
>> > news:DAA0C279-C2A0-446D-B8D3-6AA50EDF598E@microsoft.com...
>> >> The update command was created by the IDE. I did not manually change
>> >> it.
>> >> It should be correct, right?
>> >>
>> >> "Miha Markic" <miha at rthand com> wrote in message
>> >> news:%23swW1KOhIHA.1408@TK2MSFTNGP03.phx.gbl...
>> >>> "David" <david@simmonds.ca> wrote in message
>> >>> news:8C0A657C-17E1-4FBB-BE0B-09446A3C866E@microsoft.com...
>> >>>> Changing the code to use EndEdit results in the following exception
>> >>>> being thrown:
>> >>>>
>> >>>> Concurrency violation: the UpdateCommand affected 0 of the expected
>> >>>> 1
>> >>>> records.
>> >>>>
>> >>>> So, that is not the solution.
>> >>>
>> >>> On the contrary, that is the solution for your first problem. Now you
>> >>> are bumping to your second problem - update command not being
>> >>> correct.
>> >>> Check how it is coded.
>> >>>
>> >>> --
>> >>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>> >>> RightHand .NET consulting & development www.rthand.com
>> >>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>> >>>
>> >>>
>> >>
>> >
>> >
>>
>