CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: My own Database

  1. #1
    Join Date
    Aug 2000
    Posts
    22

    My own Database

    Hello,

    Can I create my own databse ?

    seocndly

    How can I save this information

    Public Type Record
    ID As Integer
    Name As String * 20
    End Type

    Dim MyRec as Record

    Myrec.Id=1
    Myrec.name="deep"
    How can I save this info to a file





  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: My own Database


    option Explicit
    'from msdn
    'to test this, put two commandbutton on a form
    private Type Record ' Define user-defined type.
    ID as Integer
    Name as string * 20
    End Type

    private Sub Command1_Click()
    Dim MyRecord as Record, RecordNumber ' Declare variables.
    ' Open file for random access.
    Open "c:\TESTFILE" for Random as #1 len = len(MyRecord)
    for RecordNumber = 1 to 5 ' Loop 5 times.
    MyRecord.ID = RecordNumber ' Define ID.
    MyRecord.Name = "My Name" & RecordNumber ' Create a string.
    Put #1, RecordNumber, MyRecord ' Write record to file.
    next RecordNumber
    Close #1 ' Close file.

    End Sub

    private Sub Command2_Click()
    Dim MyRecord as Record, Position
    Dim lentoread

    Open "c:\TESTFILE" for Random Access Read as #1 len = len(MyRecord)
    Do
    Position = Position + 1
    get #1, Position, MyRecord
    If EOF(1) then Exit Do
    me.print MyRecord.ID & " " & MyRecord.Name
    Loop While EOF(1) = false

    Close #1
    End Sub

    private Sub Form_Load()
    Command1.Caption = "writedata"
    Command2.Caption = "readData"
    End Sub





    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured