Prepare for your Next Interview
This is a discussion on Create datatable in memory within the C# forums, part of the Software Development category; If I've to read records from a text file and then to create a datatable in memory and add records in it, then how i can set the datatype ...
|
|||
|
Create datatable in memory
If I've to read records from a text file and then to create a datatable in memory and add records in it, then how i can set the datatype of each column. Formate of file 'll be like its first line will have name of columns for datatable.
Plzz tell me Question asked by visitor Sumaira |
| Sponsored Links |
|
|||
|
Re: Create datatable in memory
Hi Sumaira,
what type of data do You store in file, are those the delimitered values (like using colon or tab) or is it just plain text? as for the datatypes, hmm, it really depends what sort of data You have in those columns can You paste a sample of that data file? It would be easier then to suggest some solutions ![]() Charles |
|
|||
|
I think i have the solution for your Problem
Hi
i may be a little late to answer the question.Main Concept : Cover the text file in to an XML datafile. Assumptions Made : Your file contains | Name | some thing | Some thing | Solution elaborated : First the file is a text file so reading from the file will not be a problem ![]() Second the file is read and a equivalent XML file can be created For Example : Say a record is like this | Name | Age | Gender | | Chibi | 20 | Male | Then we can read the file with readLine() method and the break the data with the separators as the marker. on breaking this create an XML record <Student> <name> Chibi </name> <age> 20 </age> <Gender> Male </Gender> </Student> Please refer XML materials for further details in how to create the XML file correctly Then we can do things very easily. Dataset.readXML("your XML file path goes here"); method can be used to get the Data directly in to the Dataset. Use the Update method to update all the changes from the Dataset to the Database. ![]() I think that will do job. If any doubt please thread. ![]() |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Physical Memory and Virtual Memory | blenda | Windows | 4 | 3 Weeks Ago 01:15 AM |
| MemoryCleaner performs fast and powerful memory sweep, removing wasted memory blocks, | JobHelper | Geeks Lounge | 0 | 10-06-2007 07:13 AM |
| How to execute second record from run time datatable ? | bharathi_ark | QTP | 1 | 08-02-2007 02:44 PM |
| At which memory, VB Coding is stored like hot memory | Subashini.Ramasamy | VB.NET | 0 | 07-10-2007 09:43 AM |
| How to place whole table in webpage onto datatable | Geek_Guest | QTP | 0 | 05-13-2007 08:48 AM |