Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Database > ADO.NET

ADO.NET Anything regarding DataAdapters, DataReaders, DataSets, etc.

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-14-2009, 6:39 PM
VB.NET Forum Master
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Sep 2007
Age: 22
Posts: 279
Reputation: 80
Stonkie probably authored a book by nowStonkie probably authored a book by nowStonkie probably authored a book by now
Default Optimistic concurrency misses varchar fields

I am trying to create a very simple typed dataset using the designer in VS2005 to connect to my Article table on an SQL Server 2005 Express database, nothing out of the ordinary. I want to use optimistic concurrency because there will be many user working on that table.

But it seems that when I drag my table on the dataset designer's surface from the server explorer window, it does not create the update and delete queries correctly for concurrency issues detection. There are filters missing on the varchar(MAX) fields so another user may modify the article's content and I won't even know it when I overwrite their change.

This is shown on the screenshots I attached. You can see there is no filter on any of the VARCHAR(MAX) columns.

Is this caused by the full-text search option being disabled? I seems to solve the problem if I modify the DELETE and UPDATE queries manually, but I'm looking to know why it does that. Performance isn't an excuse to cut the corners that rough...
Attached Images
File Type: jpg Article table structure.JPG (46.6 KB, 9 views)
File Type: jpg Article delete query.JPG (153.8 KB, 10 views)
__________________
The human mind's capability to comprehend abstract concepts is limited to the vocabulary it can use to describe it. The more precise the building blocks, the more complex the thoughts that can emerge... Sounds like the evolution of programming languages doesn't it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-20-2009, 6:31 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

if your field is defined as varchar(max) then the designer might either:

not know what this is, because it's not VARCHAR(<number>)
know that this is a huge field, and isnt good to search and compare from a performance point of view


see what happens if you make a table with VARCHAR 100, 200, 400, 800, 1600 etc... and see if there is a cutoff point for the designer to make the field part of the search.


ps that's one wierd looking opti query. Did the designer do that?
The oracle ones look very different, ORring is done first
__________________
DW1 DW2 DW3 DW4 DNU PQ

Last edited by cjard; 01-20-2009 at 6:41 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-20-2009, 11:43 AM
VB.NET Forum Master
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Sep 2007
Age: 22
Posts: 279
Reputation: 80
Stonkie probably authored a book by nowStonkie probably authored a book by nowStonkie probably authored a book by now
Default

Quote:
see what happens if you make a table with VARCHAR 100, 200, 400, 800, 1600 etc... and see if there is a cutoff point for the designer to make the field part of the search.
You are right, whatever length I make my VARCHAR, it always produces the right query except when it's VARCHAR(MAX). If the designer could not know what the type is, I think it wouldn't map to the String type correctly so we can rule this one out. I'm thinking this is a matter of performance, yet performance isn't an issue to me as my fields are rather short.

I was just too lazy to add error handling all over my code to prevent color names or whatever from getting too long. I believe the VARCHAR(MAX) type will behave like any other VARCHAR type for size under 8KB (one page) in terms of performance so I never saw the point to limit the size of the fields. Am I circumventing best practices by doing this?

Quote:
ps that's one wierd looking opti query. Did the designer do that?
The oracle ones look very different, ORring is done first
Yes, this is the query as I just added the table to the designer. I didn't change anything. It would be simpler if it wasn't for my UpdateId and DisplayOrder nullable columns...

Anyway, I posted this question on the msdn forums and the answer was pretty much that it may be a bug or a by design decision. In any case, there's nothing to be done about it so I'll have to keep editing the queries manually and eventually remember to use Timestamp columns the next time I design a database.
__________________
The human mind's capability to comprehend abstract concepts is limited to the vocabulary it can use to describe it. The more precise the building blocks, the more complex the thoughts that can emerge... Sounds like the evolution of programming languages doesn't it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-20-2009, 8:35 PM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Quote:
Originally Posted by Stonkie View Post
You are right, whatever length I make my VARCHAR, it always produces the right query except when it's VARCHAR(MAX). If the designer could not know what the type is, I think it wouldn't map to the String type correctly so we can rule this one out. I'm thinking this is a matter of performance, yet performance isn't an issue to me as my fields are rather short.
Given that VARCHAR(MAX) is up to 2 gigabytes, you can maybe see why it would be a design decision not to bother including string comparisons of this type


Quote:
Am I circumventing best practices by doing this?
It seems not, though if your varchars arent going to exceed 8kb you can reduce your optimistic sql headache and use varchar(8000) instead of varchar(max)



Quote:
I'll have to keep editing the queries manually and eventually remember to use Timestamp columns the next time I design a database.
Nothing stopping you adding a timestamp column, or a counter in a trigger. upon every insert set the counter 0, every update, increment it by one. Your optimism can then hinge on that counter being the same as when it was downloaded.. Very similar to a timestamp, i suppose
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 9:45 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.