By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

import the decoded information/data into Microsoft Acess

P: 17
hi
im actually doing on a SMS application using Visual Basic.Net whereby the objective is to allow the user to send a SMS to the visual basic programme and i should decode out the hp no, car plate, time in,time out and date.And finally import the data(hp number, car plate number....as stated earlier) into Miscrosoft Access.I have already successfully decoded the data and May I know how i can import the decoded information/data into Microsoft Acess so that it can be stored as database in order to be retrived in the later part.Below is my programme.
Thanks
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2.  
  3. Public Class Form1
  4. Dim WithEvents serialPort As New IO.Ports.SerialPort
  5. Dim Data As String
  6. Dim buffer As String
  7. Dim Handphone_number As String
  8. Dim datetime As String
  9. Dim i As Integer
  10. Dim j As Integer
  11. Dim k As Integer
  12. Dim msg$
  13. Dim Content As String
  14.  
  15. Const HEADER = """REC UNREAD"""
  16. Const EOM = "EOM"
  17. Private Const cnstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = carpark.mdb"
-------------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.  
  3.  
  4. Timer1.Enabled = True
  5.  
  6. Try
  7. With serialPort
  8. .PortName = "COM12"
  9. .BaudRate = 115200
  10. .Parity = IO.Ports.Parity.None
  11. .DataBits = 8
  12. .StopBits = IO.Ports.StopBits.One
  13. End With
  14. serialPort.Open()
  15.  
  16. MsgBox(" connected.")
  17. Try
  18. serialPort.Write("ATE" + vbCr)
  19.  
  20.  
  21. Catch ex As Exception
  22. MsgBox(ex.ToString)
  23. End Try
  24.  
  25.  
  26. Catch ex As Exception
  27. MsgBox(ex.ToString)
  28. End Try
  29.  
  30.  
  31. End Sub
-------------------------------------------------------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2.  
  3. Try
  4. serialPort.Write("AT+CMGL=""REC UNREAD""" & vbCr)
  5.  
  6. Catch ex As Exception
  7. MsgBox(ex.ToString)
  8. End Try
  9.  
  10.  
  11. 'MSComm1.Output = "AT+CMGL=""REC UNREAD""" & vbCr
  12. End Sub
--------------------------------------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Sub Decode(ByVal m As String)
  2. Dim timestr As String
  3. Dim datestr As String
  4. Dim car_plate As String
  5.  
  6.  
  7. i = InStr(1, m, """")
  8. If (i > 0) Then
  9. j = InStr(i + 1, m, """")
  10. If (j > 0) Then
  11. Handphone_number = Mid(m, i + 1, j - i - 1)
  12. MsgBox("The Handphone number is:" + Handphone_number)
  13.  
  14.  
  15. i = InStr(j + 1, m, """")
  16. If (i > 0) Then
  17. j = InStr(i + 1, m, """")
  18. If (j > 0) Then
  19. datetime = Mid(m, i + 1, j - i - 1)
  20. datestr = Mid(datetime, 1, 8)
  21. timestr = Mid(datetime, 10, 8)
  22. MsgBox("The date is: " + datestr)
  23. MsgBox("The time is: " + timestr)
  24.  
  25.  
  26. car_plate = Mid(m, j + 1)
  27. MsgBox("The car plate number is: " + car_plate)
  28.  
  29. End If
  30. End If
  31.  
  32. End If
  33. End If
  34. End Sub
-------------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Sub DataReceived( _
  2. ByVal sender As Object, _
  3. ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
  4. Handles serialPort.DataReceived
  5.  
  6. Dim somemore As Boolean
  7.  
  8. buffer = buffer + serialPort.ReadExisting
  9. somemore = True
  10. Do While somemore = True
  11.  
  12. i = InStr(buffer, HEADER)
  13. If (i > 0) Then 'beginning of message found
  14.  
  15. j = InStr(i, buffer, EOM)
  16. If (j > 0) Then 'end of message found
  17.  
  18. msg$ = Mid(buffer, i + Len(HEADER), j - i - Len(HEADER))
  19. MsgBox(msg, vbInformation, "TEST")
  20.  
  21. Call Decode(msg$)
  22. buffer = Mid(buffer, j + Len(EOM))
  23. If Len(buffer) = 0 Then
  24. somemore = False
  25. End If
  26.  
  27. Else
  28. somemore = False
  29. End If
  30. Else
  31. somemore = False
  32. End If
  33. Loop
  34.  
  35. End Sub
-------------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Sub executeDataCommand(ByVal s As String)
  2. Dim cmd As OleDbCommand
  3. Dim cn As New OleDbConnection(cnstr)
  4.  
  5. cn.Open()
  6. cmd = New OleDbCommand(s, cn)
  7. cmd.ExecuteNonQuery()
  8. End Sub
-------------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Private Function executeDataRead(ByVal s As String) As OleDbDataReader
  2. Dim rd As OleDbDataReader
  3. Dim cmd As OleDbCommand
  4. Dim cn As New OleDbConnection(cnstr)
  5.  
  6. cn.Open()
  7. cmd = New OleDbCommand(s, cn)
  8.  
  9. rd = cmd.ExecuteReader()
  10. executeDataRead = rd
  11. End Function
  12.  
  13. End Class
-------------------------------------------------------------------------------------------------------------------
Sep 26 '07 #1
Share this Question
Share on Google+
1 Reply


Shashi Sadasivan
Expert 100+
P: 1,435
Could you please put your code into [code] tags?
What issue are u really facing?
You are already reading an Access file right?

Cheers
Sep 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.