reading flat file of fixed length and write into the data base

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: reading flat file of fixed length and write into the data base

  1. #1
    Join Date
    Dec 2005

    reading flat file of fixed length and write into the data base

    I am working as a web developer , doing project in in that by using c, they have taken the data from machine and store it as a flat file with .L extension into the directory, Now i have to read the flat file of fixed length from this directory and store it into the database table,
    The table have the fields like this
    datcallingDateTime as Date
    LgTransTime as long
    int TkNo as integer
    intServiceNo as integer
    intCounterNo as integer
    intApplicationNo as integer .....
    Since it is a flatfile i cannot see the content how it is inside,the only information i got is ,it is of fixed length,

    please help in regarding reading the flat files.

  2. #2
    Join Date
    Nov 2003
    Portland, OR
    ' Imports System.IO
    ' Imports System.Runtime.InteropServices
    Private Structure RecordType
        Public datCallingDateTime As Date
        Public lngTransTime As Long
        Public intTkNo As Integer
        Public intServiceNo As Integer
        Public intCounterNo As Integer
        Public intApplicationNo As Integer
    End Structure
    Dim handle As GCHandle
    Dim ptr As IntPtr
    Dim Record As RecordType
    Dim Buffer(Len(Record) - 1) As Byte
    Dim theFile As New FileStream("d:\path\filename.L", FileMode.Open, FileAccess.Read)
    Do Until theFile.Position >= theFile.Length
        ' Read one record into Buffer array
        theFile.Read(Buffer, 0, Buffer.Length)
        ' Copy Buffer into Record structure
        handle = GCHandle.Alloc(Buffer, GCHandleType.Pinned)
        ptr = handle.AddrOfPinnedObject()
        Record = DirectCast(Marshal.PtrToStructure(ptr, GetType(RecordType)), RecordType)
        ' -- Insert values of Record structure into database 
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Questions on VB. NET!
    By Pliroforikarios in forum .NET
    Replies: 1
    Last Post: 12-12-2005, 08:21 AM
  2. wav file fade in out help
    By jase_dukerider in forum C++
    Replies: 2
    Last Post: 04-14-2005, 07:48 PM
  3. Replies: 12
    Last Post: 05-18-2001, 04:05 AM
  4. How to create a fix length file
    By Marcia in forum Java
    Replies: 0
    Last Post: 02-02-2001, 04:23 AM
  5. Creating a fixed Length text file
    By Rob Pesce in forum VB Classic
    Replies: 2
    Last Post: 11-10-2000, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center