in the reisgter how i put it togeter time and date of the code when i keyin the admin No and admin card then it record the the access datatbase.

 Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click
    If String.IsNullOrWhiteSpace(txtcard.Text) Or String.IsNullOrWhiteSpace(txtadmno.Text) Then
        MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    Dim Conn As System.Data.OleDb.OleDbConnection
    Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"
    Conn = New System.Data.OleDb.OleDbConnection(ConnectionString)


    Try
        If Conn.State = ConnectionState.Open Then Conn.Close()
        Conn.Open()

        Dim CMD As New System.Data.OleDb.OleDbCommand
        CMD.CommandText = "Select  FROM tbl_studentadm WHERE [Stud Admin] ='" & txtadmno.Text & "' AND [Admin Card] = '" & txtcard.Text & "'"
        Dim sql As String = "insert into tbl_studentadm ([Stud Admin], [Admin Card]) values('" & txtadmno.Text & "', '" & txtcard.Text & "')"
        Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
        sqlCom.Connection = Conn

        Dim result As Integer = sqlCom.ExecuteNonQuery()

        sqlCom.Dispose()
        Conn.Close()

        If result > 0 Then
            MessageBox.Show("Successfully Register.")
        Else
            MessageBox.Show("Failure to Register.")

        End If
        txtadmno.Text = ""
        txtcard.Text = ""
        txtadmno.Focus()

        Lecturer_Form.Show()
    Catch ex As Exception
        MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try

End Sub




Private Sub Student_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If String.IsNullOrWhiteSpace(txtadmno.Text) Or String.IsNullOrWhiteSpace(txtcard.Text) Then
        MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    Using conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb")

        Dim Result As Integer
        Dim sql As String = "INSERT [Date Select] From tbl_studentadm values (@DateSelect) "
        Dim cmd As New System.Data.OleDb.OleDbCommand(sql, conn)

        cmd.Parameters.Add("@dateselect", OleDb.OleDbType.Date).Value = DTP.Value
        conn.Open()
        Result = cmd.ExecuteNonQuery()

        If Result > 0 Then
            MessageBox.Show("Successfully.")
        Else
            MessageBox.Show("This date you did have it.")
        End If

        cmd.Parameters.Clear()
        cmd.Dispose()
        conn.Close()
    End Using
    End Sub




Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    lbltime.Text = "Time:" + TimeString


End Sub

End Class

Edited 2 Years Ago by Xiao_1

If you want to use the system date and time you can use 'Now', as in:

Dim dtmNow As Date
dtmNow = DateValue(Now)

I can't remember if dtmNow.Value can be assigned directly to a OleDbType.Date field type, but you can try it and see.

This article has been dead for over six months. Start a new discussion instead.