Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Database > Database General Discussion

Database General Discussion General discussion on database related topics

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 3:56 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 11
thek is on a distinguished programming path ahead
Default Choose the right start?

Hi guys

I learned a lot in this tread

I have to realize that I (hate to say it) must start over.

So what I’m going to make, is a program that can:
  • Hold the data needed
  • Have more than one person to work in the program and updating the data (It’s not a requirement that it’s the same data/records they update (but it would be nice), but at least I’ll make a functionality that locks the data that one person is editing, so that there are no overwrite of data.
  • The database MUST be on a share network

So… I really need some advice on which kind of database I need to create/use, to make sure that the 3 above items is “do-able”.

Earlier I created it (manually) without using the wizards in visual studio, but I ended up with being way over my head. I used an Access database to do this. But – as mentioned earlier – I couldn’t make it happen.

Thanks for any help and hints
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-09-2009, 5:52 PM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 816
Reputation: 459
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

I'd recommend reading the DW2 link that cjard posted.

If you're a visual learner this series will be of assistance: Forms over Data Video Series

Here's an article on handling concurrency issues in .NET. The article is for an ASP.NET application but it does go over some of the drawbacks of pessimistic locking and provides a couple of sample stored procedures that you could build from: 15 Seconds : Handling Concurrency Issues in .NET

Last edited by MattP; 07-09-2009 at 6:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-10-2009, 2:41 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 11
thek is on a distinguished programming path ahead
Default

Quote:
Originally Posted by MattP View Post
I'd recommend reading the DW2 link that cjard posted.
Read it many times, and I can do it blindfold now ;-)
But I'm unfamiliar with, how to cahnge the navagtion bar? Can I somehow see the code behind the bar?

Quote:
If you're a visual learner this series will be of assistance: Forms over Data Video Series
Excellent. Thanks !

Quote:
Here's an article on handling concurrency issues in .NET. The article is for an ASP.NET application but it does go over some of the drawbacks of pessimistic locking and provides a couple of sample stored procedures that you could build from: 15 Seconds : Handling Concurrency Issues in .NET

Thanks again !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-10-2009, 8:14 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Quote:
But I'm unfamiliar with, how to cahnge the navagtion bar? Can I somehow see the code behind the bar?
I guess you mean the BindingNavigator? It is just bound to a BindingSource. The buttons are assigned the regular action to do, for example in MoveNextItem the default BindingNavigatorMoveNextItem button is selected. When this button is clicked the BindingSource.MoveNext method is called. If you need custom code you can doubleclick the button and write code for it's Click event, to prevent the default call to BS method you just select "(none)" for its MoveNextItem in this case.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-10-2009, 9:00 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 11
thek is on a distinguished programming path ahead
Default

Quote:
I guess you mean the BindingNavigator?
Yes.

But there is no code behind the BindingNavigatorMoveNextItem_Click, it looks like this:

Code:
Private Sub BindingNavigatorMoveNextItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextItem.Click

    End Sub
Where can I see the code that move one record forward? (When I create database access via the wizard)

If I can see the code, then I can get rid of the navigationsbar that the wizard created, and make my own button, with the code from "BindingNavigatorMoveNextItem_Click" in it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-10-2009, 12:49 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

As I said, the navigator is connected to a BindingSource (BindingSource property), then various buttons on the navigator is assigned particular actions (like the move next), when these buttons are clicked the corresponding action method on the BS is called. There is no client code necessary to do this in a default configuration. Have a look at the members of BindingSource class and you'll see it's obvious how they all map to the various navigator actions, you can also see this map in help for BindingNavigator Class (System.Windows.Forms)
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-11-2009, 4:41 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,378
Reputation: 746
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 thek View Post
Yes.

But there is no code behind the BindingNavigatorMoveNextItem_Click, it looks like this:

Code:
Private Sub BindingNavigatorMoveNextItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextItem.Click

    End Sub
Where can I see the code that move one record forward? (When I create database access via the wizard)

To say John's post another way:

You can't see it, because Microsoft wrote the BindingNavigator. It takes in a BindingSource as a parameter, and then simply calls bindingSource.MoveNext every time you click on what it knows to be the Next button (you tell it that too)

Simply put, their code might look like this:

Code:
Class BindingNavigator
  
  Private _bs as BindingSource
  Property BindSource as BindingSource
    Set
      _bs = value
    End Set
  End Property

  Private _mni as Button
  Property MoveNextItem as Button
    Set
      _mni = value
      AddHandler(_mni.Click, AddressOf(MNIClickHandler))
    End Set
  End Property

  Private Sub MNIClickHandler
    _bs.MoveNext()
  End Sub
End Class
If you really wanna see the code then use Reflector to decompile the .NET framework, but it will be like this in essence:
When the MoveNextItem is set to a button, the click handler of that button is assigned INSIDE the bindingnavigator code to a handler that is ALSO inside the bindingnavigator code
Every time you click the button, it just calls MoveNext on the bindingsource the bindingnavigator is attached to (ALSO inside the bindingnavigator code)

If you want to "roll your own" MoveNext handler you HAVE to tell the BindingNavigator it has no set MoveNextItem
-> Open the properties for the BindingNavigator
Find the MoveNextItem setting
Set it to NONE

Now you can roll your own click handler in your own code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-11-2009, 4:47 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,378
Reputation: 746
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 thek View Post
  • Hold the data needed
  • Have more than one person to work in the program and updating the data (It’s not a requirement that it’s the same data/records they update (but it would be nice), but at least I’ll make a functionality that locks the data that one person is editing, so that there are no overwrite of data.
  • The database MUST be on a share network
Use SQL Server Express

Note for item 2, you can use pessimistic locking but it is sometimes dumb. By default doing code like DW" link in my sig shows you, creates OPTIMISTIC locking, which is "hope that noone else changed the record, but throw an exception if someone did"

If 2 people d/l a record and then one changes and saves
and then the other changes and saves, he gets an exception because the query is written so that old values in the client are compared with the db values. If 0 rows are affected, it means someone changed a value

So when you get your exception you have to handle it:
Overwrite user1's changes with user2's
Keep user1's
Show user 2 both sets of changes and let them choose which of each
Merge the changes, letting user1's changes win if there is a conflict
Merge the changes, letting user2's changes win if there is a conflict

You must write this code. it is not automatic
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 1:10 PM.

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


For advertising opportunities click here.