|
Sorry for the long text...
I'm using a dataset for the link between my application and the MS Access database. The problem I have is with the Update function of the table adapter object. The code is really simple and it works very well except in one situation. Here's the code (generated by dragging from the data source to the windows form):
this.tblRequestBindingSource.EndEdit();
this.tblRequestTableAdapter.Update(this.forms_Work_LogDataSet.tblRequest);
The situation when it doesn't work is very specific and I've tried it on several test applications and it seems to be caused by the dataset. When I create a new record and save right away, everything is fine. Then, if I make a modification to the record and save again, an Concurrency Violation exception is thrown. It only happens on new records. I can save as many times as I wish on already existing records, but not on new records.
Usually, Concurrency violation exception is due to the fact that more than one user is modifying the record, but in that case, only one user is modifying the information. It seems as if the first update didn't "EndEdit" even though it was clearly done if you look at my code. That's not good because when I call the update method of the table adapter, it's trying to update every changes made in that table of the dataset, meaning I can never save changes in the application data unless I restart the application because it's always throwing the exception.
I read many things on bypassing concurrency violation exceptions, and for the dataset, it seemed pretty logical to just remove the "optimistic concurrency" option. It didn't work, because well, that's probably not even the reason why it's throwing that exception.
I was wondering if this problem can be solved, without switching to a disconnected mode. I want a solution or a reason as to why we cannot insert a new record and save more than once without leaving the application. This problem can easily be reproduced by dragging a data source on a form and trying exactly what I wrote that isn't working fine. If someone has a solution for that, I'd really appreciate the help.
BTW, I won't accept "Don't use datasets" as an answer unless there really isn't an other solutions...
|
|
|
|
|
Which DataAdapter class are you using? If you're using the OdbcXxx family, ensure you're using the Access ODBC driver directly by specifying
Driver={Microsoft Access Driver (*.mdb)} If using OLE DB (OleDbConnection etc) the situation is reversed - ensure that you're not trying to use the OLE DB wrapper around ODBC (MSDASQL). If you're using a DSN you will be using this implicitly, likewise if you don't specify a provider. Use this for OleDbConnection:
Provider=Microsoft.Jet.OLEDB.4.0 People have reported that although Jet is COM-based internally, ODBC connections can be faster because the P/Invoke overhead is lower than the COM Interop overhead.
As an experiment, you could see if the problem also occurs if using the other type of adapter, or with a different provider and database engine, e.g. SQL Server Compact Edition[^] (which is also an in-process database engine).
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
I'm already using jet oledb 4.0 as the provider in the connection string. I haven't tried using a different data adapter though. I'll try that.
Thanks
|
|
|
|
|
Are you using an autonumber as the primary key? If so the adapter.update will not return the number to the data table. to correct for this add a rowchanged event to the adapter and use the code shown below to retrieve the IDENTITY value. This may fix your problem.
adapter.RowUpdated += new OleDbRowUpdatedEventHandler(OnRowUpdateed);
private void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs e)
{
if (e.StatementType == StatementType.Insert)
{
using (OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY", e.Command.Connection))
{
e.Row["Id"] = cmd.ExecuteScalar();
e.Row.AcceptChanges();
}
}
}
William T
modified on Wednesday, June 4, 2008 4:47 AM
|
|
|
|
|
Could anybody suggest a scrolling banner/marquee (vertical & horizontal) that works well with .aspx pages?
Thanks
|
|
|
|
|
check out http://www.dynamicdrive.com/[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Dear All,
I have an application which i want to integrate with other applications. My application will be running all the time (running on the tray icon) . I have implemented the keyboard hooking to catch a hot key F1 for exmple and call my application. What i need is to read a field value from the external applicaion and call my application passing that value as a parameter (Command()...)
Please give me key about where to look
Thanks in advance
Best Regards
3ala2
|
|
|
|
|
You don't mention what language you're developing in. If it is a .NET language, then .NET Remoting would be a perfectly acceptable tool.
|
|
|
|
|
There are multiple ways you can do it:
a) .Net Remoting
b) Windows Communication Foundation
c) Web Service
d) WMI events
Tariq A Karim
http://moplah.blogspot.com/
|
|
|
|
|
Hi,
I have an class liabrary. To debug this liabrary when my application gets started, I try attaching the process (VS 2005 -> Debug -> Attach to process) but the debug symbol does not get loaded.
Also when I try to debug the project (F5), I get the following error "The operation could not be loaded. Parameter is incorrect"
Is there an debugger setting that missing out in this class liabrary project?
Regards,
Vipul Mehta
Regards,
Vipul Mehta
|
|
|
|
|
You need to make sure you have compiled everything in DEBUG mode, and that you have access to the .pdb file generated by the compiler for the assembly you want to debug.
|
|
|
|
|
Hi All,
Would someone plese tell me what the error :"The request failed with HTTP status 400: Bad Request" means. I am getting this when I try to send huge amount of data to web service.
Regards,
Ash.
|
|
|
|
|
Hi,
Even i am getting same kind of error .. but no one has replied yet 
|
|
|
|
|
The error just means that the web service for some reason didn't like the request. Specifically, it may mean that the web service:
a) can't understand your request (bad headers/bad encoding/bad data).
b) has failed when processing your data (due to a bug or bad data).
c) doesn't accept your request (invalid data, too much data or whatever other rule it may enforce).
So as you see, the reasons can be infinitely many, and there is no simple answer. You may be doing something wrong, the web service may be doing something wrong or there may be a problem on the way (corrupting the request).
It's almost impossible to debug without carefully analyzing the entire raw request (including HTTP headers) and/or debugging the web service itself. If you didn't create the web service you could try sending the request to a fake web service you create and capture it there - then you have to analyze it for correctness somehow (proof-reading it or building a program that analyzes it) and finally, if you're certain it's correct, contact the ones responsible for the web service.
I think I remember seeing it intermittently in .NET 1.1 due to some bug or quirk (the request headers sometimes were incorrectly generated by the framework). Both the web service and consumer were built in .NET, and the error occured before my (web service) code even saw the request. Spent hours of fruitless debugging before I found the bug on Google... Haven't heard about that in a long time though - I think it got fixed in an early service pack.
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
One more thought: You say "huge amount of data"... could it be that the web service has a limit on the amount of data it accepts and you are exceeding it? That would qualify as a "bad request"...
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
Hi, how could we determine whether visual studio 2005 sp1 is installed in our system? Thank in advance
|
|
|
|
|
Go to Visual Studio > Help > About Visual Studio
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Thank you very much for your reply. I used to run windows update and i found that my computer require to update vs 2005 sp1. Then I download from an internet (431 Mb). I installed it but during the time that it is nearly finish (remain around 1mn) the eletricity was disconnect and i try to use the command
shutdown -s -f -t: 5 to force shutdown my machine before the electricity cut off. So I'm not sure whether i could install vs 2005 sp1 successfully or not. But when i try to run windows update again i fould that my computer still require vs 2005 sp1. So I doubt that it might not install properly. Thank in advance.
|
|
|
|
|
Look in the about box of VS2005.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
|
What is the difference between WriteLine and Print methods of Debug class?
|
|
|
|
|
They are identical. In other words, they call exactly the same function internally.
You may find Reflector.NET handy for these situations.
|
|
|
|
|
Thanks leppie.
Do you know why then two methods with exactly the same functionality exist?
|
|
|
|
|
Maybe for legacy reasons. I didnt even know a Print method existed till you said it
|
|
|
|
|
Hi All,
I am currently working with web services and while sending data to web service i am getting this Error:
"The request failed with HTTP status 400: Bad Request"
Can anyone tell me why i am getting this Errr ...
Regards,
Perry
|
|
|
|