I have a DataGridView using DataTable as my datasource. Now my problem is how do I keep my datatable synchronised to our server database? Like for example somebody tried to update the database so automatically my datatable will be updated too. Without using iteration. Is this possible?
There is nothing automatic in software. We need to automate things that seems to be automatic. You can use caching mechanism for your solution. The datatable can be filled using a cache. The cache can be made invalid on change of underlying tables in the database. And upon invalidating, the datatable shall have to be recreated again and so the gridview shall have to be updated.
If you are using ASP.NET, you can refer the MSDN article on the same here: http://msdn.microsoft.com/en-us/library/ms972379.aspx
Is this using WPF or Windows Forms?
Simple way: each client regularly polls the server and updates as needed.
More complex way: service oriented using callbacks, for example, http://www.switchonthecode.com/tutorials/wcf-tutorial-events-and-callbacks.
Related
I am creating an application and some of the information relies on data found in an SQL table. On pageload, this is bound to a ListView, but how do I get the list to auto refresh (re-bind) if more data is added to the SQL table?
I have considered calling the bind every 10 seconds or so, but that seems to be a bit old fashioned.
Any tips?
What you have is called Pulling Data from server.
What you want is called pushing data to Client.
Try SignalR for pushing data.
I have successfully bound a SQLite database table to a DevExpress XtraGrid control, and can see the few test rows I have, and can also edit the values, and commit the changes back to the database with an Update command upon closing.
My question is what would be the best way for me to insert rows to the table? I have implemented and successfully used some example code for inserting rows into a SQLite table, however I am uncertain if the DevExpress XtraGrid has some type of method to allow me to skip all of the example code I have, and simply use the same functionality that seems to be already built into the control.
So should I use example code that connects to the database, builds the query then runs it on the database, or is there a better way, using something already built into the DevExpress WinForms suite?
Thanks.
You can use Embedded Navigator controls to insert rows !
https://www.devexpress.com/Support/Center/Question/Details/Q235790
After some research, I found that the best way to interact with the data in the grid, or with any database for that matter, is to use DevExpress's eXpress Persistent Objects for .NET. Great bit of technology. It allowed me to specify the database and table I was interested in, and it created all of the plumbing to allow me to deal with rows in the table like normal C# objects with properties.
If you are struggling with trying to mix in SQL queries and the like into your application, I highly recommend you make your life much easier and use XPO.
Here is a link to the documentation describing XPO: http://documentation.devexpress.com/#XPO/CustomDocument1998
I have an ASP.Net website, that uses a MySQL database.
First of all, because the Connect/Net of MySQL doesn't install on PC (reason unknown, no error, it just doesn't work) I'm using ODBC for the connection.
I've written some nice wrapper classes for using the database, and it's all working ok.
But now I'm adding a little Silverlight application to my website (first thing I'm making with WCF/Silverlight, without actually reading any tutorial, so let's hope for the best).
Now this application won't be anything fancy, it's only for the administrators, to read the logs, and change some configuration settings, etc, nothing fancy at all. But what it has to do is retrieve data from the services.
What I've done is a setup a service reference, and it works like a blessing, but now I'm trying to read the logs from the service, and I'm getting in trouble, because my class was never built to serialize to XML, first issue. And secondly I wouldn't know how to bind the retrieved data at the client to the datagrid.
I'm going to parse the recordset at the server so that I'll be sending a class containing an array of columns, and a multi-dimensional with the data to the client, now that's not much of a problem, I'm just mentioning it so that you can either improve or keep in mind what the data will look like.
My question: How would I bind that retrieved data to a plain <sdk:DataGrid>?
You can create your own in-memory DataSet/DataTable without it being hooked up to any particular database. You can populate it yourself using anything you want in the Silverlight application. Bind your DataGrid to it after you've filled it, as you normally would do on a simple client/server ASP.NET application.
Take the retrieved data from the web service, and populate a dataset. Then bind the dataset to the datagrid. You need to write some code-behind code for this, but not much. You can't do it all in the presentation layer's XAML.
(Edit: clarification for client/server/silverlight model)
I already have a dynamic XtraPivotGrid creation, but the table adapter and the dataset are 1(one) table specific. I want to be able to get data from a table specified by user, but I can't see a way of doing this without writing about 2.5k lines of code (writing the same code the IDE creates in design time, but for any table). Does anybody think in an easier way of doing this?
In similar situations I was creating the XtraGrid in design time, but then just changed the DataSource at runtime based on the user table selection. Then I was using the built in methods of XtraGrid to automatically create the columns. There is an article at DevExpress that might help.
I am a newbie to Database programming. After inserting a couple of rows into a DataSet object, I am trying to write back the updated DataSet to the Database but cannot figure out how to do it.
Can you give an example for the following please?
what SQL insert command to use if DataSet is already updated with new rows
Databinding example - especially considering an initially empty table in the DB
I am using SQLExpress 2008 & its C# WinForms application.
thanks
ps: I have already looked at the related questions here. This one is different in that I am first adding my new data into a DataSet and want to update the DB then.
What you need to do is configure a DataAdapter or TableAdapter object that contains the proper Update command. Then when you are done updating the rows in your DataSet, you can call DataAdapter.Update(DataSet) and it will do all the hard work for you.
Since you're starting out, I'd suggest looking at the TableAdapter objects that are built using the XSD schema tool. They allow you to simply drop your tables into the XSD to create a schema, and then let the wizard generate the appropriate SQL commands (it'll even do Stored Procedures for you) to handle all the CRUD work. I've been using these for a while and love them.
EDIT: In response to Sesh's request, Scott Gu has a great tutorial series on using the Table Adapters here. I wanted to post this in the answer so others can find it easily.