Results 1 to 3 of 3

Thread: Create datatable in memory

  1. #1

    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

  2. #2
    Junior Member
    Join Date
    Nov 2007

    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

    can You paste a sample of that data file?

    It would be easier then to suggest some solutions


  3. #3
    Junior Member
    Join Date
    Dec 2007

    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
    <name> Chibi </name>
    <age> 20 </age>
    <Gender> Male </Gender>

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.