To avoid polling MS Excel file, I am looking something similar to SqlDependency class which can alert the application about changes in the file.
Also, is there something similar like SQL Change Tracking feature, for MS Excel (2010 or above)?
My sole purpose is to display excel file contents in GridView and update GridView with the newly inserted rows in excel.
I went through ListObject.Change Event, but it works for a selected range and returns the cells which are changed. But I am in need to newly inserted or deleted rows (no cell-editing or updating required).
You can subscribe to the Workbook.SheetChanged event for changes to any sheet in the workbook, or the Worksheet.Change event for changes to a particular sheet.
Excel has no concept of "adding" or "deleting" rows like SQL, so there's no way to pinpoint to just those types of events - you'll have to determine what changed in your event handler and decide if you want to do anything about it or not.
Or stop using Excel as a database :)
Related
I made a Winforms application that displays rows of data in a DataGridView. I want to add a function that searches for specific rows based on text that the user enters in a Textbox. I have found examples that use SQL queries but I did not construct my DataGridView from an SQL database data source, I filled in each row manually one-by-one with strings and ints.
https://www.c-sharpcorner.com/UploadFile/1e050f/search-record-in-datagridview-C-Sharp/
I am new to databases and I have a conceptual question. Can I create a temporary database at runtime without needing to install a password-protected database onto my system? This program is one that I share with colleagues as an .exe file and I don't want them to need to download and install an SQL database with a specific username/password just to run the program. I don't want the data stored in the database to persist when the program exits. I just want to be able to create a database and query it so I can implement a good search function for my DataGridView while the program is actually running. My program generates a completely new DataGridView at runtime based on the .txt log file that the user provides and has no need for data to persist between runs.
You don't need a Database behind your program to filter your DataGridView.
Instead of generating the DataGrid directly:
retrieve and save your data in a separate list
Filter the list using Linq and save the filtered result in a query
apply the query result to your DataGridView DataSource
I am using xtrareports with my c# project and i ran into a problem. When i change the structure of one of my database table, the reports that depended on it needed to be created again because the datasource did not automatically updated itself. is there a way of doing this so that the reports are updated with the new updated datasource without having to make reports again?
Solution could be the below:
Create and configure datasets in your project
Bind a Report to a Data Source Schema
Now if you have any changes in database then update the DataSet which you added in project according the database table structure changes. It will help you easily fix the reports for the small changes e.g. column name change, column datatype
After that just open the reports in designer and again configure/modify report for the changes you made to the dataset.
Hope this way you reduce your efforts to recreate the reports from scratch..
If you mean when you add/modify a column in a procedure that feeds your report, you can:
Right click your data source in the field list menu and hit "Rebuild Result Schema"
I have looked at the various levels(application, workbook, and worksheet) of the Excel.Interop libraries to find out how to detect a user sorting data. I have created a class that instantiates an application, workbook, and worksheet. The program has data piped in from another application and then adds it to a worksheet. I am using .NET 4.5, C# compiler version 4.0, and have been testing with Excel 2013 if that makes a difference.
I can detect cell changes and calculation events but neither of those events fire when a column is sorted. I believed that it should work after reading this article.
After having that fail for me, I looked into the table update event but I had no luck. There error I received was along the lines of, "the handler does not exist in the Microsoft.Office.Interop.Excel namespace, are you missing an assembly. I don't think this is the right direction I need to go but I was attempting to see if it would suit my needs.
Using any other method besides the Excel Interop method might set me back a few weeks.
Is there something I am missing in regards to the table update event handler or perhaps the sort event itself?
I have created the MongoDB Service and writing values to MongoDB using one program. Another program would need to subscribe to these changes. Like Events. Whenver a collection gets a new value I need to get a call back to my new C# program. Is this possible ?
Its possible using the Tail-able Cursor in MongoDB. Create the MongoDB service as a replica service.Create only primary server(if more than one server is not used.).Oplog table will be create in the MongoDB Server. This table will get reflected for each and every changes happens in the database. The table details which are changed will be present in the Oplog table,
Create a Tailable cursor in the table and create an Event and event listener to listen to the changes in this table.
Tailable cursor
This is the only work around solution I can find out till now. Its works like a charm !! :). As I have started working on QT C++ and SQlite I forgot about this qustion. Hope this helps anyone in future.
I don't think that this i possible. I would implement another Document in the MongoDB, where all changes are inserted to. Your second program can check for new changes in the Document. Than you have a robust pull-system. Maybe you can call the Document some thing like Notification or ChangeLog.
(Solution without ReplicaSet)
I have a table attached to a gridview in asp.net.
Lets say a user edits a row and updates the text in a textbox. I need to able to know what column he has modified and highlighted (ie make it bold).
This information needs to persist outside of the asp.net session so it would need to come from the DB.
How to go about pulling this info from the DB?
Add one more column to of updateTime in table and create a afterUpdate trigger which will insert updated time in that column.
Now you can differentiate the rows which have been updated recently from all other rows.