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
[code=vbnet]
Imports System.Data.Ole Db
Public Class Form1
Dim WithEvents serialPort As New IO.Ports.Serial Port
Dim Data As String
Dim buffer As String
Dim Handphone_numbe r As String
Dim datetime As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim msg$
Dim Content As String
Const HEADER = """REC UNREAD"""
Const EOM = "EOM"
Private Const cnstr = "Provider = Microsoft.Jet.O LEDB.4.0;Data Source = carpark.mdb"[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Timer1.Enabled = True
Try
With serialPort
.PortName = "COM12"
.BaudRate = 115200
.Parity = IO.Ports.Parity .None
.DataBits = 8
.StopBits = IO.Ports.StopBi ts.One
End With
serialPort.Open ()
MsgBox(" connected.")
Try
serialPort.Writ e("ATE" + vbCr)
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As System.EventArg s) Handles Timer1.Tick
Try
serialPort.Writ e("AT+CMGL=""RE C UNREAD""" & vbCr)
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
'MSComm1.Output = "AT+CMGL="" REC UNREAD""" & vbCr
End Sub[/code]
--------------------------------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub Decode(ByVal m As String)
Dim timestr As String
Dim datestr As String
Dim car_plate As String
i = InStr(1, m, """")
If (i > 0) Then
j = InStr(i + 1, m, """")
If (j > 0) Then
Handphone_numbe r = Mid(m, i + 1, j - i - 1)
MsgBox("The Handphone number is:" + Handphone_numbe r)
i = InStr(j + 1, m, """")
If (i > 0) Then
j = InStr(i + 1, m, """")
If (j > 0) Then
datetime = Mid(m, i + 1, j - i - 1)
datestr = Mid(datetime, 1, 8)
timestr = Mid(datetime, 10, 8)
MsgBox("The date is: " + datestr)
MsgBox("The time is: " + timestr)
car_plate = Mid(m, j + 1)
MsgBox("The car plate number is: " + car_plate)
End If
End If
End If
End If
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports .SerialDataRece ivedEventArgs) _
Handles serialPort.Data Received
Dim somemore As Boolean
buffer = buffer + serialPort.Read Existing
somemore = True
Do While somemore = True
i = InStr(buffer, HEADER)
If (i > 0) Then 'beginning of message found
j = InStr(i, buffer, EOM)
If (j > 0) Then 'end of message found
msg$ = Mid(buffer, i + Len(HEADER), j - i - Len(HEADER))
MsgBox(msg, vbInformation, "TEST")
Call Decode(msg$)
buffer = Mid(buffer, j + Len(EOM))
If Len(buffer) = 0 Then
somemore = False
End If
Else
somemore = False
End If
Else
somemore = False
End If
Loop
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub executeDataComm and(ByVal s As String)
Dim cmd As OleDbCommand
Dim cn As New OleDbConnection (cnstr)
cn.Open()
cmd = New OleDbCommand(s, cn)
cmd.ExecuteNonQ uery()
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Function executeDataRead (ByVal s As String) As OleDbDataReader
Dim rd As OleDbDataReader
Dim cmd As OleDbCommand
Dim cn As New OleDbConnection (cnstr)
cn.Open()
cmd = New OleDbCommand(s, cn)
rd = cmd.ExecuteRead er()
executeDataRead = rd
End Function
End Class[/code]
-------------------------------------------------------------------------------------------------------------------
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
[code=vbnet]
Imports System.Data.Ole Db
Public Class Form1
Dim WithEvents serialPort As New IO.Ports.Serial Port
Dim Data As String
Dim buffer As String
Dim Handphone_numbe r As String
Dim datetime As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim msg$
Dim Content As String
Const HEADER = """REC UNREAD"""
Const EOM = "EOM"
Private Const cnstr = "Provider = Microsoft.Jet.O LEDB.4.0;Data Source = carpark.mdb"[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Timer1.Enabled = True
Try
With serialPort
.PortName = "COM12"
.BaudRate = 115200
.Parity = IO.Ports.Parity .None
.DataBits = 8
.StopBits = IO.Ports.StopBi ts.One
End With
serialPort.Open ()
MsgBox(" connected.")
Try
serialPort.Writ e("ATE" + vbCr)
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As System.EventArg s) Handles Timer1.Tick
Try
serialPort.Writ e("AT+CMGL=""RE C UNREAD""" & vbCr)
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
'MSComm1.Output = "AT+CMGL="" REC UNREAD""" & vbCr
End Sub[/code]
--------------------------------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub Decode(ByVal m As String)
Dim timestr As String
Dim datestr As String
Dim car_plate As String
i = InStr(1, m, """")
If (i > 0) Then
j = InStr(i + 1, m, """")
If (j > 0) Then
Handphone_numbe r = Mid(m, i + 1, j - i - 1)
MsgBox("The Handphone number is:" + Handphone_numbe r)
i = InStr(j + 1, m, """")
If (i > 0) Then
j = InStr(i + 1, m, """")
If (j > 0) Then
datetime = Mid(m, i + 1, j - i - 1)
datestr = Mid(datetime, 1, 8)
timestr = Mid(datetime, 10, 8)
MsgBox("The date is: " + datestr)
MsgBox("The time is: " + timestr)
car_plate = Mid(m, j + 1)
MsgBox("The car plate number is: " + car_plate)
End If
End If
End If
End If
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports .SerialDataRece ivedEventArgs) _
Handles serialPort.Data Received
Dim somemore As Boolean
buffer = buffer + serialPort.Read Existing
somemore = True
Do While somemore = True
i = InStr(buffer, HEADER)
If (i > 0) Then 'beginning of message found
j = InStr(i, buffer, EOM)
If (j > 0) Then 'end of message found
msg$ = Mid(buffer, i + Len(HEADER), j - i - Len(HEADER))
MsgBox(msg, vbInformation, "TEST")
Call Decode(msg$)
buffer = Mid(buffer, j + Len(EOM))
If Len(buffer) = 0 Then
somemore = False
End If
Else
somemore = False
End If
Else
somemore = False
End If
Loop
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Sub executeDataComm and(ByVal s As String)
Dim cmd As OleDbCommand
Dim cn As New OleDbConnection (cnstr)
cn.Open()
cmd = New OleDbCommand(s, cn)
cmd.ExecuteNonQ uery()
End Sub[/code]
-------------------------------------------------------------------------------------------------------------------
[code=vbnet]
Private Function executeDataRead (ByVal s As String) As OleDbDataReader
Dim rd As OleDbDataReader
Dim cmd As OleDbCommand
Dim cn As New OleDbConnection (cnstr)
cn.Open()
cmd = New OleDbCommand(s, cn)
rd = cmd.ExecuteRead er()
executeDataRead = rd
End Function
End Class[/code]
-------------------------------------------------------------------------------------------------------------------
Comment