![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#11
| |||
| |||
|
#12
| |||
| |||
|
|
Hi, I wrote a very simple program to test concurrency with sql server 2005. I used the VS 2005 dataset designer wizard to create my dataset and and tableadapter. When I ran the program, I used the debugger to stop the code before the tableadapter.update(row) method was called. I then ran the server explorer and modified the data row and then continued with the program. To my surprise, no error was thrown! The row was not updated(as expected) because the where clause did not match. How do I check for concurrency? My test data table has two columns. the first column is an auto incremented integer primary key. The second column is just and integer field. Here is my program: using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace ConcurrencyTest { class Program { static void Main(string[] args) { TestDataSet testDS = new TestDataSet(); TestDataSetTableAdapters.TestTableAdapter testTA = new TestDataSetTableAdapters.TestTableAdapter(); TestDataSet.TestDataTable testDT = testTA.GetDataBy(1000); TestDataSet.TestRow testRow = testDT[0]; testRow.count++; try { testTA.Update(testRow); } catch (DBConcurrencyException e) { String data = e.Message; } catch (Exception e) { String data = e.Message; } } } } here is what the update looks like: UPDATE Test SET count = @count WHERE (TestId = @Original_TestId) AND (count = @Original_count) Troy |
#13
| |||
| |||
|
|
oops. I accidentally posted that without the testdataset.designer.cs snippet. Here it is: FYI: a snippet of the testdataset.designer.cs: this._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Test] SET [count] = @count WHERE (([TestId] = @Original_TestId) AND" + " ([count] = @Original_count));\r\nSELECT TestId, count FROM Test WHERE (TestId = @" + "TestId)"; |
#14
| |||
| |||
|
|
Troy, Something crazy is happening, I will probably search for this tomorrow. There are no update commands anymore generated on my computer. [snip] |
#15
| |||
| |||
|
|
Did you remember to set your primary key? I heard that without it the update does not get generated. Troy Cor Ligthert [MVP] wrote: Troy, Something crazy is happening, I will probably search for this tomorrow. There are no update commands anymore generated on my computer. [snip] |
#16
| |||
| |||
|
|
Did you remember to set your primary key? I heard that without it the update does not get generated. Troy Cor Ligthert [MVP] wrote: Troy, Something crazy is happening, I will probably search for this tomorrow. There are no update commands anymore generated on my computer. [snip] |
#17
| |||
| |||
|
#18
| |||
| |||
|
|
I think I found the problem. See: http://search.support.microsoft.com/...d=8291&sid=200 I haven't been able to get the hotfix yet to try it though. [snip] |
#19
| |||
| |||
|
|
Troy , I don't think so, If I was using as you had showed, (what was fine for me, I never did it that way), than the update was *not* processed. Because I always use a datatable attached to the Server I have attached that created one. In that case when I set a breakpoint before the update, changed it as you wrote and went on, I got a concurrency error (nd when I did not change it not) "Inbreuk op gelijktijdige uitvoering: 0 van de verwachte 1 records zijn beïnvloed door de UpdateCommand." If you don't believe me, ask somebody who speaks Dutch To summarize with the not connected mdf file the update was completely not processed. I did it now in a windowform, but that did it either with a standalone mdf as I have tested this. I have not tested it with a consoleapplication but I expect the same results. I hope you get the same result. Cor troy (AT) makaro (DOT) com> schreef in bericht news:1156918959.393633.39410 (AT) p79g2000cwp (DOT) googlegroups.com... I think I found the problem. See: http://search.support.microsoft.com/...d=8291&sid=200 I haven't been able to get the hotfix yet to try it though. [snip] |
#20
| |||
| |||
|
|
Troy , I don't think so, If I was using as you had showed, (what was fine for me, I never did it that way), than the update was *not* processed. Because I always use a datatable attached to the Server I have attached that created one. In that case when I set a breakpoint before the update, changed it as you wrote and went on, I got a concurrency error (nd when I did not change it not) "Inbreuk op gelijktijdige uitvoering: 0 van de verwachte 1 records zijn beïnvloed door de UpdateCommand." If you don't believe me, ask somebody who speaks Dutch To summarize with the not connected mdf file the update was completely not processed. I did it now in a windowform, but that did it either with a standalone mdf as I have tested this. I have not tested it with a consoleapplication but I expect the same results. I hope you get the same result. Cor troy (AT) makaro (DOT) com> schreef in bericht news:1156918959.393633.39410 (AT) p79g2000cwp (DOT) googlegroups.com... I think I found the problem. See: http://search.support.microsoft.com/...d=8291&sid=200 I haven't been able to get the hotfix yet to try it though. [snip] |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |