Solved

VB.NET Datagrid and Update database

Posted on 2002-05-03
10
460 Views
Last Modified: 2010-05-02
Hi,

I'm using the standard datagrid in vb.net with an connection to an access database.

I want to start up my program twice, on different PC's.

When changes made with the datagrid in the database, I manage to update my database. But how do I see that in the other window. A refresh button with the command FILL to fill in the grid again fails. When I close the first window and use the refresh button, then it works.

Do i have to close something from my database, connection,...?

Is it possible to auto refresh when changes are made?


Thanks

Frederik
0
Comment
Question by:FrederikBonte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6988255
>>I close the first window and use the refresh button, then it works

DataSet does not automatically update the database. You need an Update statement. Don't forget that everything is disconnected in ADO.Net.

>>Is it possible to auto refresh when changes are made?

You will need something that requires an update (ie a timer)
0
 

Author Comment

by:FrederikBonte
ID: 6993070
A timer, yes i thought so to, but then what if someone is making changes at that moment.

Can you see if the grid is in editing mode or not?

Thanks

Frederik
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6993563
You need to trap some KeyPress events to reset the Timer to 0. If you have (because I didn't find one) a sample of a screen saver in .Net, you need to use this way.

Before doing the refresh, I hope that you will call the Update.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:FrederikBonte
ID: 6993633
Maybe, it depends. I one screens timer is activated, then the grid will do a refresh, even if on the other screen the grid is in editing mode.

Is there no way to force the refresh when the data has changed instead of with a timer. It seems like asking for trouble

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6993642
you should add a button to your form that will update the database and refresh by the same time.
0
 

Author Comment

by:FrederikBonte
ID: 6993664
I think we are talking next to eachother

My Database is installed on the server

My program is running on 2 different pc's with network connection and are pointing to the same database.

The edit, add and delete are done inside the grid.

If I start editing a record on one pc, and i have a timer who is to refresh each 10 seconds, then i have to make sure I end the editing before the time is up or I can restart.

When done editing the program on the other pc should also refresh.

Btw, an addition prob, is there automatic recordlocking

Thanks,

Fred
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6993811
your dataset is not supposed to be bounded. So you don't lock anything!
0
 

Author Comment

by:FrederikBonte
ID: 6993840
Its not bound

I Just create an OLEDBConnection
Then I made an OLEDBDataAdapter
Which I used to create a DataSet
This Dataset is used as datasoure for my datagrid

Do i have to bound stuff to have recordlocking?

And still the first question, how do i know my datagrid is being edited

I will increase points and give you another question while i'm at it :)

Can I set the column width of my grid per column, I don't find such a simple thing that I could in VB6. I know it should be in there but where.

Thanks for all you efforts.

Fred

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 250 total points
ID: 6993854
because you are disconnected from the database, the database does not know what the users are doing so no locking can be done.

have a look at
http://www.syncfusion.com/FAQ/WinForms/default.asp#44
0
 

Author Comment

by:FrederikBonte
ID: 6993897
thanks thats a great link

points are flying first class to you

Thanks again for your time and effort

Frederik
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question