Hey
My problem is this - I made a WinForm application that is used to input data into a database, but I don't know how can I save that database and load it back to my application. The application has to be able to receive new data and save it to a new database (the schema of the database is always the same), and to open, display and manipulate any databases that have been created before (by the same application). I'm using DataGridView for data display. I've made the application using Visual Studio 2010.
TNX
Neven DraskovicPosted Dec 19, 2011, 4:08 AM
Again thank you very much, I am very grateful for your help and patience.
Sam HobbsPosted Dec 14, 2011, 10:58 AM
Probably what you are trying to say is that you want a report or a query of boards in a session. You probably do not need a file; you just need to query the database and create a report. You can show the data in a DataGridView so it is shown in a grid, similar to a spreadsheet. Or you can create a report that is typically printed. You might be able to use my article Database Table Update in a DataGridView without Writing Code to show the data in a grid. For reports you can use either Crystal Reports or Reporting Services.
Is there something in the database table that indicates what session the board was tested in? A session id and/or a date and time or something like that?
Neven DraskovicPosted Dec 14, 2011, 10:24 AM
As for the session - try to picture it as packing a lot of small boxes (information about each card) into a larger box (final report). That report contains all informations about every single card. The test itself is very simple - every card is inserted into the reader, and if the reader reads the cards serial number then it is certain that the card is functioning properly. That test is repeated for each card.
But I think we drifted off with this, because for my original question the data in the database, and the way I'm obtaining it, is not important (because I already solved that part). What I don't know is literally how to make a file that represents a database (the database contains only one table, so it is pointless to classify it as relational or any other). So my question is: what routine do I have to make to enable the user to click on a button, and by doing so create a file (I don't even know the proper extension) that can be loaded into some other database manipulating program, and display the data stored in there. Let me use the Office Word analogy. When you make a document in word and click the "Save" button, a Document.doc is created, and it can later be opened from Word. I need to do the same thing, just with a database.
I know that my "explanations" raise more questions than they actually explain anything, but as you probably realized, English is not my native tongue, so my vocabulary is limited. Anyway, I am extremely grateful for your patience, but I am rather new to this level of programming, and I really need outside assistance. Thanks again
Sam HobbsPosted Dec 14, 2011, 9:44 AM
There might a critical requirement that you are not telling us but I am not sure. I get the impression however that you are not trying hard enough to understand what I said. If that is not a problem then I apologize. Sometimes people try harder to explain to the other person what they think the person does not understand instead of trying to understand what the person is saying. I don't want to get in a loop where we just keep saying the same thing.
You seem to be saying that you need to keep each test session separate. The boards tested in a session need to be related (hear that; they are related by the test session). If they are not related in that manner then I totally do not understand. If they are related in that manner then saying they are not makes it impossible for me to help you.
Neven DraskovicPosted Dec 14, 2011, 3:17 AM
Sam HobbsPosted Dec 13, 2011, 3:11 PM
Neven DraskovicPosted Dec 13, 2011, 6:00 AM
Thanks
Sam HobbsPosted Dec 13, 2011, 5:32 AM
What you call a session would have been called a batch in the past. Many computer systems create transaction batches and then the batches are processed to update the master file. This could be done for a jet aircraft's parts list or it could be done by a companie's accounting department. I don't know if modern software uses the concept of a batch.
You can store each session separately. You can have one table of sessions, identified by date and time and by other identifying information. A session or batch could also have a user associated with the batch. Then your other table could have the details identified by the session/batch id or whatever. This would be the relational database solution and it would be one (the one?) that DBA people would like to see.
Neven DraskovicPosted Dec 13, 2011, 4:50 AM
What it is doing at this point:
The application reads data from a serial port (the serial port has a card reader connected to it, and it reads the serial numbers of the cards), stores it in a database, with some other info that user defines. All the data from the database is displayed in a DataGridView control that has all the columns that the database has + 2 button columns for deleting and marking (user's request, probably unimportant but I want to give you the whole picture). When user has inputed all the data that he wants, the application creates a simple report by writing every DataGridView cell value (except for the button columns of course ) into an Excel table. This is the description of the basic functionality of my application, I still have some refining to do, but the basic request has been satisfied.
What else it should do:
The user has requested that every "session" is recorded so it can be reopened somewhere in the future. After the "session" is completed, the application has to be able to receive new data that will not influence or be influenced by the previous "session(s)". Important - when user opens one of the records, he can browse the data, but no changes to the data are allowed (the data has to be sealed so to say). So after the "session" is over, no data can be added or removed from the record. Another problem I'm having is with the serial port reading. The problem is that my current solution displays a messageBox that the card has been read from - this is too slow if working with large number of cards. However I cant put the reading into a loop because the user will be unable to stop it. Now the only way to solve this that I can think of is by using threads, but I never worked with them so I would like to avoid them if it's possible.
This is more or less everything the application has to do - so do you have any ideas or instructions, please share. Also if I still haven't clarified any part of the request, please ask, and I will try to define it better.
Thanks again
Sam HobbsPosted Dec 12, 2011, 7:00 PM
In most database tables, there is a primary key that identifies each record. For example a customer has a customer id. For your table, will the records also have a primary key that identifies the records and most records will always have the same primary key? If so then it is confusing to say that you are inserting records.
It is difficult to understand what you need to do.
Neven DraskovicPosted Dec 12, 2011, 9:16 AM
Saving process
- Fill the applications built-in database (this part is solved)
- By clicking the "Save" button make a copy of that database and store it in newly created external database on C: or any other storage device
- Delete all data from applications built-in database (so it can receive new data) and empty the DataSet that feeds the DataGridView
Opening process
- Fill the built-in database from a stored database
- Re-fill the DataGridView's DataSet so the proper data is displayed (since the DataSet and the database are directly connected, all manipulation from the application should manifest itself in the built-in database)
- No changes should be applied to external database, unless the user rewrites it.
I managed to export my data to Excel document, but one of the requirements is that all the data is saved into an independent database, so do you know any articles or tutorials that can help me with this problem.
Thanks again
Datta KharadPosted Dec 12, 2011, 8:51 AM
Refer this article...
http://www.c-sharpcorner.com/uploadfile/5eae74/database-operations-using-dataset/