Datagrid Update Problem

  • Thread starter Thread starter Reney
  • Start date Start date
R

Reney

I have a very weird problem in updating my datagrid. Please help me to solve
it. The datagrid is tied to a dataset table with five columns. Three of them
are primary key and the other two columns are the ones that are of interest.
These
two columns have "date" type values and shows short time (i.e. 11:39).
The program updates the database if I change the values in these columns, or
add a new record, or
delete a record. But, if one of these two columns have null value, it won't
let me to enter a new value to that column. And the error it gives is
"concurrency
violation. 0 rows are updated." Again, if one of these two columns have null
value,
and if I try to modify the other column's value, again it doesn't do the
update and the
error tells that it cannot cast "" string to date type.

Please give me any idea that might help me to solve this problem,
Thanks in advance
Reney
 
Hi Reney,

You came to us yesterday with your query. Unfortunately no-one has had a
solution for you.

I've got a couple of questions that may take us a bit further. :-)

1) When you say 'updating when a date is null'. Do you mean that you can
create a new record with one valid date and one null and <then> you can't
change the null date? Or do you mean that you can't create a new record with a
null date <in the first place>?

2) What happens if you try and update where <both> dates are null. Same
error? or does it only happen when one is null?

3) What constraint, if any, have you set up on these fields in the
database. Are they set to must-be-non-null? It's possible, perhaps, that you
are getting a misleading error message pointing you in the wrong direction.

4) Can you update new records in Access itself - ie. manually. If not,
does it give the same error message or something more useful?

Regards,
Fergus
 
Hi Fergus, thanks for your interest. Let me explain the problem a little
bit further. In the program, a user can clock-in (Simply the current
time is written in the "ClockStart" column of the TimeLog table). User
can also clock out with the same procedure(Those are accomplished with
another form class). The form that I am working on and having problems
is the timelog form, where a user can view all the clock-ins and outs
for the previous week.
This is shown with a datagrid. What I am trying to do is, if the user
forgot to clock out, a clock out value could be entered using this
datagrid later.

In this datagrid, I can change the clock-in and clock-out values and
update it successfuly. It also lets me to delete records or add new
records if I enter all the fileds in the correct format. But if the
clock-out value is null (which means, the user has clocked in first, but
not clocked out yet), I cannot update the datagrid when I enter a new
time value in the clock out field. This error is given:
"Concurrency violation: the update command affected 0 records."

And in response to you questions:
1) When you say 'updating when a date is null'. Do you mean that you can
create a new record with one valid date and one null and <then> you
can't change the null date? Or do you mean that you can't create a new
record with a
null date <in the first place>?


Actually, in this form, I cannot create a new record with a null value
in one of the date fields. Then this error is given:
"Cast from type 'DBNull' to type 'Date' is not valid. Do you want to
correct the value?"

2) What happens if you try and update where <both> dates are null. Same
error? or does it only happen when one is null?

It gives me the same error as it gives when one is null.
"Concurrency violation: the update command affected 0 records."

3) What constraint, if any, have you set up on these fields in the
database. Are they set to must-be-non-null? It's possible, perhaps, that
you are getting a misleading error message pointing you in the wrong
direction.

I haven't set up any constraints on these two fields in the database.
Their required field is set to 'No'(with Access terminology), they have
data/time data type with short time format.

4) Can you update new records in Access itself - ie. manually. If not,
does it give the same error message or something more useful?

In Access, I can update them manually without any error.

I hope I could explain the problem clearly. Please let me know if there
is anything not clear enough. Thanks for your time,
Reney
 
Hi Reney,

I was hoping that you'd be able to report something out of the ordinary
and we could point our fingers and say "Aha!!". Unfortunately that isn't the
case and I have reached the limit of my knowledge in this area.

This newsgroup is actually for issues with VB itself, although we get
asked allsorts. Those of us who know anything about databases will help as
best we can.

There is, however, a dedicated ADO.NET newsgroup where the real database
experts hang out:
news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet

Maybe someone else <here> who will have some more ideas, but I'd recommend
that you post your query to the ADO people too.

If you do, make sure that you provide all the information that you have
given us, ie. your original post plus the Update SQL from your response to One
Handed Man and finally the answers to my questions above. Giving them all the
information will save them asking questions that you already have the info
for.

Sorry I can't take you to a conclusion. :-(
All the best. :-)

Regards,
Fergus
 
Hi Fergus,

Thanks for taking your time to help me, and also providing me the ado
news group's link. I will go ahead and post my question in this group
now.

Best regards,
Reney
 
Back
Top