How to compare variable in table of Visual basic database
up vote
1
down vote
favorite
I made an MS Access DB table and added in visual basic to be work with Arduino. The table has columns (SerialNumber, Name, RFID_Number, Date/time, foodtype) I can send the RFID tag from arduino to visual basic windows program.
then I want to know how to use this variable coming from Arduino through serial to be compared in table for example: IF RFID number match with date/time then send command to arduino to open servo1 to give the dog his food.
the program made for three dogs =D to serve them their food on time a day.
My question how to compare the variable in table DB.
This is my whole code in visual basic which now I can recieve the RFID number from Arduino.
Imports System
Imports System.IO.Ports
Public Class Form1
Dim comPORT As String
Dim receivedData As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SpringdbDataSet.SpringData' table. You can move, or remove it, as needed.
Timer1.Enabled = False
comPORT = ""
For Each sp As String In My.Computer.Ports.SerialPortNames
comPort_ComboBox.Items.Add(sp)
Next
Me.SpringDataTableAdapter.Fill(Me.SpringdbDataSet.SpringData)
SerialNumberTextBox.Clear()
FullnameTextBox.Clear()
RFIDTagTextBox.Clear()
SpringSizeTextBox.Clear()
OperationTimeDateTimePicker.Value = Now
End Sub
Private Sub PreBnt_Click(sender As Object, e As EventArgs) Handles PreBnt.Click
SpringDataBindingSource.MovePrevious()
End Sub
Private Sub AddBnt_Click(sender As Object, e As EventArgs) Handles AddBnt.Click
SpringDataBindingSource.AddNew()
End Sub
Private Sub SaveBnt_Click(sender As Object, e As EventArgs) Handles SaveBnt.Click
Try
SpringDataBindingSource.EndEdit()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Success")
Catch ex As Exception
MsgBox("Error occur, please recheck the fields and try again.")
End Try
End Sub
Private Sub DeleteBnt_Click(sender As Object, e As EventArgs) Handles DeleteBnt.Click
SpringDataBindingSource.RemoveCurrent()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Current Record Deleted")
End Sub
Private Sub NextBnt_Click(sender As Object, e As EventArgs) Handles NextBnt.Click
SpringDataBindingSource.MoveNext()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
SpringDataBindingSource.Filter = "SerialNumber LIKE '%" & TextBox1.Text & "%'" & " OR Fullname LIKE '%" & TextBox1.Text & "%'"
End Sub
Private Sub comPort_ComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comPort_ComboBox.SelectedIndexChanged
If (comPort_ComboBox.SelectedItem <> "") Then
comPORT = comPort_ComboBox.SelectedItem
End If
End Sub
Private Sub connect_BTN_Click(sender As Object, e As EventArgs) Handles connect_BTN.Click
If (connect_BTN.Text = "Connect") Then
If (comPORT <> "") Then
SerialPort1.Close()
SerialPort1.PortName = comPORT
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
SerialPort1.ReadTimeout = 10000
SerialPort1.Open()
connect_BTN.Text = "Dis-connect"
Timer1.Enabled = True
Timer_LBL.Text = "Timer: ON"
Else
MsgBox("Select a COM port first")
End If
Else
SerialPort1.Close()
connect_BTN.Text = "Connect"
Timer1.Enabled = False
Timer_LBL.Text = "Timer: OFF"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
RFIDTagTextBox.Text &= receivedData
End Sub
Function ReceiveSerialData() As String
Dim Incoming As String
Try
Incoming = SerialPort1.ReadExisting()
If Incoming Is Nothing Then
Return "nothing" & vbCrLf
Else
Return Incoming
End If
Catch ex As TimeoutException
Return "Error: Serial Port read timed out."
End Try
End Function
Private Sub Timer_LBL_Click(sender As Object, e As EventArgs) Handles Timer_LBL.Click
End Sub
Private Sub RFIDTagTextBox_TextChanged(sender As Object, e As EventArgs) Handles RFIDTagTextBox.TextChanged
End Sub
End Class
database visual-studio-2010
add a comment |
up vote
1
down vote
favorite
I made an MS Access DB table and added in visual basic to be work with Arduino. The table has columns (SerialNumber, Name, RFID_Number, Date/time, foodtype) I can send the RFID tag from arduino to visual basic windows program.
then I want to know how to use this variable coming from Arduino through serial to be compared in table for example: IF RFID number match with date/time then send command to arduino to open servo1 to give the dog his food.
the program made for three dogs =D to serve them their food on time a day.
My question how to compare the variable in table DB.
This is my whole code in visual basic which now I can recieve the RFID number from Arduino.
Imports System
Imports System.IO.Ports
Public Class Form1
Dim comPORT As String
Dim receivedData As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SpringdbDataSet.SpringData' table. You can move, or remove it, as needed.
Timer1.Enabled = False
comPORT = ""
For Each sp As String In My.Computer.Ports.SerialPortNames
comPort_ComboBox.Items.Add(sp)
Next
Me.SpringDataTableAdapter.Fill(Me.SpringdbDataSet.SpringData)
SerialNumberTextBox.Clear()
FullnameTextBox.Clear()
RFIDTagTextBox.Clear()
SpringSizeTextBox.Clear()
OperationTimeDateTimePicker.Value = Now
End Sub
Private Sub PreBnt_Click(sender As Object, e As EventArgs) Handles PreBnt.Click
SpringDataBindingSource.MovePrevious()
End Sub
Private Sub AddBnt_Click(sender As Object, e As EventArgs) Handles AddBnt.Click
SpringDataBindingSource.AddNew()
End Sub
Private Sub SaveBnt_Click(sender As Object, e As EventArgs) Handles SaveBnt.Click
Try
SpringDataBindingSource.EndEdit()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Success")
Catch ex As Exception
MsgBox("Error occur, please recheck the fields and try again.")
End Try
End Sub
Private Sub DeleteBnt_Click(sender As Object, e As EventArgs) Handles DeleteBnt.Click
SpringDataBindingSource.RemoveCurrent()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Current Record Deleted")
End Sub
Private Sub NextBnt_Click(sender As Object, e As EventArgs) Handles NextBnt.Click
SpringDataBindingSource.MoveNext()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
SpringDataBindingSource.Filter = "SerialNumber LIKE '%" & TextBox1.Text & "%'" & " OR Fullname LIKE '%" & TextBox1.Text & "%'"
End Sub
Private Sub comPort_ComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comPort_ComboBox.SelectedIndexChanged
If (comPort_ComboBox.SelectedItem <> "") Then
comPORT = comPort_ComboBox.SelectedItem
End If
End Sub
Private Sub connect_BTN_Click(sender As Object, e As EventArgs) Handles connect_BTN.Click
If (connect_BTN.Text = "Connect") Then
If (comPORT <> "") Then
SerialPort1.Close()
SerialPort1.PortName = comPORT
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
SerialPort1.ReadTimeout = 10000
SerialPort1.Open()
connect_BTN.Text = "Dis-connect"
Timer1.Enabled = True
Timer_LBL.Text = "Timer: ON"
Else
MsgBox("Select a COM port first")
End If
Else
SerialPort1.Close()
connect_BTN.Text = "Connect"
Timer1.Enabled = False
Timer_LBL.Text = "Timer: OFF"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
RFIDTagTextBox.Text &= receivedData
End Sub
Function ReceiveSerialData() As String
Dim Incoming As String
Try
Incoming = SerialPort1.ReadExisting()
If Incoming Is Nothing Then
Return "nothing" & vbCrLf
Else
Return Incoming
End If
Catch ex As TimeoutException
Return "Error: Serial Port read timed out."
End Try
End Function
Private Sub Timer_LBL_Click(sender As Object, e As EventArgs) Handles Timer_LBL.Click
End Sub
Private Sub RFIDTagTextBox_TextChanged(sender As Object, e As EventArgs) Handles RFIDTagTextBox.TextChanged
End Sub
End Class
database visual-studio-2010
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I made an MS Access DB table and added in visual basic to be work with Arduino. The table has columns (SerialNumber, Name, RFID_Number, Date/time, foodtype) I can send the RFID tag from arduino to visual basic windows program.
then I want to know how to use this variable coming from Arduino through serial to be compared in table for example: IF RFID number match with date/time then send command to arduino to open servo1 to give the dog his food.
the program made for three dogs =D to serve them their food on time a day.
My question how to compare the variable in table DB.
This is my whole code in visual basic which now I can recieve the RFID number from Arduino.
Imports System
Imports System.IO.Ports
Public Class Form1
Dim comPORT As String
Dim receivedData As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SpringdbDataSet.SpringData' table. You can move, or remove it, as needed.
Timer1.Enabled = False
comPORT = ""
For Each sp As String In My.Computer.Ports.SerialPortNames
comPort_ComboBox.Items.Add(sp)
Next
Me.SpringDataTableAdapter.Fill(Me.SpringdbDataSet.SpringData)
SerialNumberTextBox.Clear()
FullnameTextBox.Clear()
RFIDTagTextBox.Clear()
SpringSizeTextBox.Clear()
OperationTimeDateTimePicker.Value = Now
End Sub
Private Sub PreBnt_Click(sender As Object, e As EventArgs) Handles PreBnt.Click
SpringDataBindingSource.MovePrevious()
End Sub
Private Sub AddBnt_Click(sender As Object, e As EventArgs) Handles AddBnt.Click
SpringDataBindingSource.AddNew()
End Sub
Private Sub SaveBnt_Click(sender As Object, e As EventArgs) Handles SaveBnt.Click
Try
SpringDataBindingSource.EndEdit()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Success")
Catch ex As Exception
MsgBox("Error occur, please recheck the fields and try again.")
End Try
End Sub
Private Sub DeleteBnt_Click(sender As Object, e As EventArgs) Handles DeleteBnt.Click
SpringDataBindingSource.RemoveCurrent()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Current Record Deleted")
End Sub
Private Sub NextBnt_Click(sender As Object, e As EventArgs) Handles NextBnt.Click
SpringDataBindingSource.MoveNext()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
SpringDataBindingSource.Filter = "SerialNumber LIKE '%" & TextBox1.Text & "%'" & " OR Fullname LIKE '%" & TextBox1.Text & "%'"
End Sub
Private Sub comPort_ComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comPort_ComboBox.SelectedIndexChanged
If (comPort_ComboBox.SelectedItem <> "") Then
comPORT = comPort_ComboBox.SelectedItem
End If
End Sub
Private Sub connect_BTN_Click(sender As Object, e As EventArgs) Handles connect_BTN.Click
If (connect_BTN.Text = "Connect") Then
If (comPORT <> "") Then
SerialPort1.Close()
SerialPort1.PortName = comPORT
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
SerialPort1.ReadTimeout = 10000
SerialPort1.Open()
connect_BTN.Text = "Dis-connect"
Timer1.Enabled = True
Timer_LBL.Text = "Timer: ON"
Else
MsgBox("Select a COM port first")
End If
Else
SerialPort1.Close()
connect_BTN.Text = "Connect"
Timer1.Enabled = False
Timer_LBL.Text = "Timer: OFF"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
RFIDTagTextBox.Text &= receivedData
End Sub
Function ReceiveSerialData() As String
Dim Incoming As String
Try
Incoming = SerialPort1.ReadExisting()
If Incoming Is Nothing Then
Return "nothing" & vbCrLf
Else
Return Incoming
End If
Catch ex As TimeoutException
Return "Error: Serial Port read timed out."
End Try
End Function
Private Sub Timer_LBL_Click(sender As Object, e As EventArgs) Handles Timer_LBL.Click
End Sub
Private Sub RFIDTagTextBox_TextChanged(sender As Object, e As EventArgs) Handles RFIDTagTextBox.TextChanged
End Sub
End Class
database visual-studio-2010
I made an MS Access DB table and added in visual basic to be work with Arduino. The table has columns (SerialNumber, Name, RFID_Number, Date/time, foodtype) I can send the RFID tag from arduino to visual basic windows program.
then I want to know how to use this variable coming from Arduino through serial to be compared in table for example: IF RFID number match with date/time then send command to arduino to open servo1 to give the dog his food.
the program made for three dogs =D to serve them their food on time a day.
My question how to compare the variable in table DB.
This is my whole code in visual basic which now I can recieve the RFID number from Arduino.
Imports System
Imports System.IO.Ports
Public Class Form1
Dim comPORT As String
Dim receivedData As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SpringdbDataSet.SpringData' table. You can move, or remove it, as needed.
Timer1.Enabled = False
comPORT = ""
For Each sp As String In My.Computer.Ports.SerialPortNames
comPort_ComboBox.Items.Add(sp)
Next
Me.SpringDataTableAdapter.Fill(Me.SpringdbDataSet.SpringData)
SerialNumberTextBox.Clear()
FullnameTextBox.Clear()
RFIDTagTextBox.Clear()
SpringSizeTextBox.Clear()
OperationTimeDateTimePicker.Value = Now
End Sub
Private Sub PreBnt_Click(sender As Object, e As EventArgs) Handles PreBnt.Click
SpringDataBindingSource.MovePrevious()
End Sub
Private Sub AddBnt_Click(sender As Object, e As EventArgs) Handles AddBnt.Click
SpringDataBindingSource.AddNew()
End Sub
Private Sub SaveBnt_Click(sender As Object, e As EventArgs) Handles SaveBnt.Click
Try
SpringDataBindingSource.EndEdit()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Success")
Catch ex As Exception
MsgBox("Error occur, please recheck the fields and try again.")
End Try
End Sub
Private Sub DeleteBnt_Click(sender As Object, e As EventArgs) Handles DeleteBnt.Click
SpringDataBindingSource.RemoveCurrent()
TableAdapterManager.UpdateAll(SpringdbDataSet)
MsgBox("Current Record Deleted")
End Sub
Private Sub NextBnt_Click(sender As Object, e As EventArgs) Handles NextBnt.Click
SpringDataBindingSource.MoveNext()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
SpringDataBindingSource.Filter = "SerialNumber LIKE '%" & TextBox1.Text & "%'" & " OR Fullname LIKE '%" & TextBox1.Text & "%'"
End Sub
Private Sub comPort_ComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comPort_ComboBox.SelectedIndexChanged
If (comPort_ComboBox.SelectedItem <> "") Then
comPORT = comPort_ComboBox.SelectedItem
End If
End Sub
Private Sub connect_BTN_Click(sender As Object, e As EventArgs) Handles connect_BTN.Click
If (connect_BTN.Text = "Connect") Then
If (comPORT <> "") Then
SerialPort1.Close()
SerialPort1.PortName = comPORT
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
SerialPort1.ReadTimeout = 10000
SerialPort1.Open()
connect_BTN.Text = "Dis-connect"
Timer1.Enabled = True
Timer_LBL.Text = "Timer: ON"
Else
MsgBox("Select a COM port first")
End If
Else
SerialPort1.Close()
connect_BTN.Text = "Connect"
Timer1.Enabled = False
Timer_LBL.Text = "Timer: OFF"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
RFIDTagTextBox.Text &= receivedData
End Sub
Function ReceiveSerialData() As String
Dim Incoming As String
Try
Incoming = SerialPort1.ReadExisting()
If Incoming Is Nothing Then
Return "nothing" & vbCrLf
Else
Return Incoming
End If
Catch ex As TimeoutException
Return "Error: Serial Port read timed out."
End Try
End Function
Private Sub Timer_LBL_Click(sender As Object, e As EventArgs) Handles Timer_LBL.Click
End Sub
Private Sub RFIDTagTextBox_TextChanged(sender As Object, e As EventArgs) Handles RFIDTagTextBox.TextChanged
End Sub
End Class
database visual-studio-2010
database visual-studio-2010
asked Nov 7 at 7:35
Mohammad Khaled
467
467
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185170%2fhow-to-compare-variable-in-table-of-visual-basic-database%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password