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









share|improve this question


























    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









    share|improve this question
























      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









      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 7:35









      Mohammad Khaled

      467




      467





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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




















































































          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini