none RFID recording Time In/Out and save it into the database. I`m begging for HELP! RRS feed

  • Question

  • I am doing a system which is a Gate Pass ID System using RFID. but im stock on how to record its time in/out (Labeltimeinout.text) in my database(mySQL) and displays "IN" on the first tap and "OuT" on the second tap. 7 days left and I`m still stuck here =( here`s my code...

    Imports MySql.Data.MySqlClient

    Public Class MainDisplay
        Dim str As String = "server=localhost; user id=root;pwd=; database=userinfo"
        Dim con As New MySqlConnection(str)
        Public idnumber As String
        Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBoxTag.KeyPress

            If Asc(e.KeyChar) = "13" Then
                Dim sqlreader As MySql.Data.MySqlClient.MySqlDataReader
                Dim query As New MySqlCommand("select concat_ws('',LastName,',',FirstName,',',MiddleName) as FullName,concat_ws('',Year,'-',Course) as YearCourse, IDNumber from userinformation where RFIDTag='" & TextBoxTag.Text & "'", con)
                Dim D As Date = Now()
                sqlreader = query.ExecuteReader

                LabelName.Text = sqlreader.Item("FullName")
                LabelYearCourse.Text = sqlreader.Item("YearCourse")
                LabelIDNum.Text = sqlreader.Item("IDNumber")


                LabelTimeInOut.Text = Format(Now, "hh:mm:ss tt")
                TextBoxTag.Text = ""
                LabelStatus.Text = ""
            End If

        End Sub

        Private Sub MainDisplay_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            labelDateInOut.Text = DateAndTime.Now.ToString("MM-dd-yyyy")
        End Sub

        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            labelmdtime.Text = TimeOfDay.ToString("hh:mm:ss tt")

        End Sub

        Private Sub ButtonMDBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonMDBack.Click
        End Sub

        Private Sub TimerLabel_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerLabel.Tick
            If TimerLabel.Interval = 1000 Then
                LabelName.Text = ""
                LabelYearCourse.Text = ""
                LabelIDNum.Text = ""
                LabelStatus.Text = ""
                PictureBox.Image = Nothing
            End If

        End Sub

    Sunday, November 11, 2018 10:35 PM

All replies

  • Hi,

    I made  a demo,save the current time in the database,and show whether it is in or out.

    Imports System.Data.SqlClient
    Public Class Form1
        Dim inout As Boolean
        Dim constr As String = "Data Source = (localdb)\MSSQLLocalDB; Integrated Security = True ;AttachDbFileName= C:\Users\alexl2\Desktop\DataBase\Alex\alex.mdf"
        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim time = Format(Now, "hh:mm:ss tt")
            inout = IIf(inout = True, False, True)
            Dim state As String = IIf(inout, "IN", "OUT")
            Using conn = New SqlConnection(constr)
                cmd = New SqlCommand("insert into Inout  values (@time,@state)", conn)
                cmd.Parameters.AddWithValue("@time", time)
                cmd.Parameters.AddWithValue("@state", state)
            End Using
        End Sub
    End Class

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, November 12, 2018 5:42 AM