CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    9

    storing data in a database through com port using mscomm command

    Hi ! can anybody help me
    Ihave written the following codes to store received data from the com port.i am communicating with a device through rs 232.The device is not present with me to check my codes.i can receive and send data from a text box line by line.Now i want to store the received data one line in a record then next received line on next record and so on, for further manipulation.
    i am confused of the use of timer.these codes give me no error at present.
    Please tell me will this codes work ? Same data get stored in textbox1 and textbox5.
    codes for storing data in a data base should be written within the timer control ???? or within the IF and END IF. OR i have to use two timer, one to receive a character and other to receive a line.Something like timer within a timer.

    Private Sub Timer1_Timer()

    If (MSComm1.InBufferCount > 0) Then

    strInput = MSComm1.Input
    Text1.Text = Text1.Text + strInput
    Text5.Text = Text5.Text + strInput

    End If

    'storing input data in a data base
    Data2.RecordSource = "SELECT * FROM rxmsg WHERE SER=" & ser
    Data2.Refresh
    Data2.Recordset.Edit
    Data2.Recordset.Fields("RXMSG") = Text5.Text
    Data2.UpdateRecord
    ser = ser + 1
    Text5.Text = ""
    End Sub

  2. #2
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: storing data in a database through com port using mscomm command

    Do not use a timer to select data from the input buffer since there is every chance that you will loose data. Instead use the onComm event of the comm control using a select case statement for the type of event.

    You can place a call here to enter data into the database, but I'd have some kind of test first to ensure you have all the data you want before writting to the database.
    If you find my answers helpful, dont forget to rate me

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