I need help. I am currently building data management applications using Winforms and C#. This application has been installed on 10 computers and are connected to one database on the server. Network only in the office.
These applications use the data grid view to display a list of employees.
The main problem now, if users on PC-A has entered a new record or update employee records, data grid view on PC-B is not updated automatically. So if I want to refresh the data grid view on PC-B, I need to press the "REFRESH" button to reload the record.
So the question is now, there are other ways to 'Data Grid View' can be updated automatically?
I do not know what it is named this method, so I hope there is anyone willing to help me in solving this problem. If the my question is already exist, hope someone can give me a link.
Thanks for help :)
In order to achieve what you want, you will need to do some fairly complex architecture work. There is no simple fix here, I am afraid.
The problem is that you want your data girds to update based on an EVENT, however that event occurs outside the application in the database. In order to register that EVENT, you will need to have a class or service which is responsible for handling all INSERTS/UPDATES/DELETES.
If you define all of your tables or views as ARTICLES, you could then have a Publisher / Subscriber model. The Data service would handle all the inserts updates and deletes for the application, and push notifications that an ARTICLE has changed to all the Subscribers for the article. On each page you could have a Class which subscribes to an Article which relates to the data displayed on your data grid, and when it receives a message that the article has been updated, rebinds the data grid to the data source.
Try reading this WIKIPEDIA article on the Observer pattern to get an idea of what the architecture might look like.
http://en.wikipedia.org/wiki/Observer_pattern
You can add Version column to a data base table, then you should ask data base periodically (pooling) to get records with has a greater version than a last received
Related
When the user double click on a row on the datagridview, the relevant details appear in the textboxes.
User can edit the details and click on Update button to save the updates on the SQL database.
Note : CustomerID is an identity column in the customer table on the database
Please help with the C# code.
Capture of Program
I presume that you've just started to learn WinForms & C#. Firstly, I would recommend that at this stage, you should keep the datagrid view as just a view.
Second, it would be better if you start off by making a simple search button to query your SQL database and populate the textboxes accordingly. Then you can keep on building up your application as you get more sophisticated with how everything works.
Step-by-step dude, nobody is just going to paste an entire code here specifically for you, and even if somebody does, you'll learn nothing.
I don't think I need to post any code but if I need to I will.
I have created a Windows Form in Visual Studio that creates a record and saves it into a database. I have also added an update function so that I can change the record and save the new changes.
What I need to know though is how to create some kind of version history. i.e. When I click update, I want it to save the previous version so that I can look back at it. Like a bug tracker has a kind of version control but a lot simpler (hopefully).
Would I need a separate database? Could I have another datagridview that when a record is clicked on (or a button) it will show the history of changes for that record?
I've done many searches online and just can't find how to do it or where to look exactly to find this?
Any help would be greatly appreciated.
Thanks
you are talking about audit trail , take look at this :Link
I know this example for MVC but it's the same idea
you only need one table to track changes of the whole database by using json objects that represent "before" and "after"
Im trying to do something similar to the Scheduling of posts for Facebook pages... on ASP.net/c#
So basically what i need is :
User fills a few text boxes
Selects a date...
The post gets posted on that date...
I am unable to really understand the logic as well as coding for this...
What i have thought so far is, once the user submits the post, store the details in a table in SQL like SheduledPosts, and when the CurrentDate(Server Date) matches the date....
Transfer the SQL entry from there to the actual PostTable.
Now the actual process needs to take place without any pages loading or any actions done by the user... So I also dont understand how to make it happen from the server side...
Please note that im not trying to post anything to facebook... rather, trying to do a schedule form submitting on my own asp.net website...
Any help regarding the logic, coding, scheduling will be greatly appriciated...
Thank You
I can think of a couple of different ways to accomplish this:
Implement a "pending posts" table and have a separate process running on the server to take care of transferring the post from the "pending posts" table to the "current posts" table at the appropriate time.
Add a "publish_on" datetime field to your current posts table, and when selecting items to be displayed in the page output, add a "WHERE publish_on IS NULL OR publish_on > GETDATE()" clause to your query. You fill this in for posts you don't want going live until a particular time.
Personally, I would go with the second approach, since I think it's a more elegant solution.
You can do this with one table. Just have a 'Submitted' date field (for your records), a 'Publish' date field and a Boolean 'Published' field. Create a Windows Service to run every 5 minutes or so and let the service perform the date check; when it finds one that satisfies the date criteria, it just toggles the Boolean field to 'true' and your page logic can then display the post.
Here is a walk-through on creating a simple Windows Service:
https://msdn.microsoft.com/en-us/library/zt39148a%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
GridView in my ASP.NET application is working very slowly when changing pages. I know that this is most probably caused by a lot of data being pooled out of database each time page is updated but I don’t know how to fix this since I’m not to ASP.NET.
My current configuration is GridView with ObjectDateSource and paging enabled. I don’t have any code behind or anything similar. ObjectDataSource is bined to typed data set.
You are correct about the cause of this – it’s the fact that you have to get all the data from database even if you only want to display one small part. For example, you retrieve 5000 rows from DB only to display 15 rows in current page.
Solution for this is implementing custom paging.
In order to get this to work with your current configuration you’ll need to update your current select method to accept the starting index and maximum number of rows input parameters and also update following properties in your grid view
“StartRowIndexParameterName”, “MaximumRowsParameterName”, “SelectCountMethod”.
Here is a great article that covers what you need but there are also a lot of topics here on StackOverflow that cover this topic.
I found the same problem and implemented a custom gridview which is now opensource, you can find it here https://github.com/vcliment89/GridViewEX. You don't need to implement all the gridview but there's an example of a custom pager on the demo project.
I am creating a web application using Dot net 3.5(c#).
Needs:
One user is accessing the entry page(Updating the database)
Another user is in report page. Once the table get updated i want to show popup message to indicate the user about the update in the database.
Is it possible to achieve this task. How to do this.
It's possible, but to do it your report page has to use ajax requests on a timer to check with the server for new records.
It seems that you can apply SQLCacheDependency for your issue. You can compare is it fit to your requirements when read this article from ASP.NET website.
Better approach is to use the
SqlCacheDependency class so that data
remains cached until its underlying
data has been modified in the SQL
database. This tutorial shows you how.
You can try LinqToCache for a LINQ sensible wrapper around the Query Notifications infrastructure used by SqlDependency and the like. You can read this article to understand how SqlDependency works.
This will give you the active notifications mechanism for your web app to detect changes that occur on the database. For the popup part, there are well know methods using various Comet techniques.