My textbox6 represents the dateprinted of my asssessment form.. i code it like this :

TextBox6.Text = My.Computer.Clock.LocalTime.Date

then in the my SAVE Button coded like this :

Dim cn As OleDbConnection
    If TextBox1.Text = "" Then
        MsgBox("Enter a Student Number! ", MsgBoxStyle.Information, "Warning")
    ElseIf TextBox1.TextLength = 9 Then
        con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\user\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
        Dim ewaaa As String = "Select * from Assessment  where StudentNumber = '" & TextBox1.Text & "'"
        com = New OleDbCommand(ewaaa, con)
        con.Open()
        com.ExecuteNonQuery()
        rid = com.ExecuteReader
        rid.Read()
        If (rid.HasRows) Then
            TextBox1.Text = rid(0)

            cn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb;Persist Security Info=False;")
            cn.Open()

            cmd = New OleDbCommand("UPDATE Assessment SET DatePrinted = '" & TextBox6.Text & "'And YearLevels = '" & TextBox3.Text & "' And Sections = '" & TextBox4.Text & "' ", cn)
            cmd.ExecuteNonQuery()

            cn.Close()
            MsgBox("Assessment Updated", MsgBoxStyle.Information, "Update")
            TextBox1.Clear()
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
            TextBox5.Clear()
            TextBox6.Clear()
            TextBox7.Clear()
            TextBox8.Clear()
            TextBox9.Clear()
            TextBox11.Clear()
            txt2PFull.Clear()
            txt2PTwo.Clear()
            txt2PThree.Clear()
            txt3PTwo.Clear()
            txt3PFull.Clear()
            txt3PThree.Clear()
            txtTPTwo.Clear()
            txtTPFull.Clear()
            txtTPThree.Clear()
            txtUEFull.Clear()
            txtUEThree.Clear()
            txtUETwo.Clear()
            TxtIDFull.Clear()
            TxtIDTwo.Clear()
            TxtIDThree.Clear()
            TxtPTAFull.Clear()
            TxtPTATwo.Clear()
            TxtPTAThree.Clear()
            TxtMiscFull.Clear()
            TxtMiscTwo.Clear()
            TxtMiscThree.Clear()
            ListView1.Items.Clear()

        End If
    Else

        con = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\user\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
        da.SelectCommand = New OleDbCommand("Select* from Assessment", con)
        Dim cmd = New OleDbCommandBuilder(da)
        If con.State = ConnectionState.Closed Then con.Open()
        ds = New DataSet
        da.Fill(ds, "Assessment")
        ds.Tables("Assessment").Rows.Add()
        lastrow = ds.Tables("Assessment").Rows.Count - 1
        myrow = ds.Tables("Assessment").Rows.Item(lastrow)
        myrow.Item("StudentNumber") = TextBox1.Text
        myrow.Item("StudentNames") = TextBox2.Text
        myrow.Item("YearLevels") = TextBox3.Text()
        myrow.Item("Sections") = TextBox4.Text
        myrow.Item("DatePrinted") = TextBox6.Text()
        ds.Tables("Assessment").GetChanges()
        cmd.GetInsertCommand()
        da.Update(ds, "Assessment")
        MsgBox("Assessment Successful")
        con.Close()

            TextBox1.Clear()
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
            TextBox5.Clear()
            TextBox6.Clear()
            TextBox7.Clear()
            TextBox8.Clear()
            TextBox9.Clear()
            TextBox11.Clear()
            txt2PFull.Clear()
            txt2PTwo.Clear()
            txt2PThree.Clear()
            txt3PTwo.Clear()
            txt3PFull.Clear()
            txt3PThree.Clear()
            txtTPTwo.Clear()
            txtTPFull.Clear()
            txtTPThree.Clear()
            txtUEFull.Clear()
            txtUEThree.Clear()
            txtUETwo.Clear()
            TxtIDFull.Clear()
            TxtIDTwo.Clear()
            TxtIDThree.Clear()
            TxtPTAFull.Clear()
            TxtPTATwo.Clear()
            TxtPTAThree.Clear()
            TxtMiscFull.Clear()
            TxtMiscTwo.Clear()
            TxtMiscThree.Clear()
            ListView1.Items.Clear()


    End If

then the output of my Textbox6 in my database become 0 or -1 . i dont know why happen like that... can you please help me? thank you in advance..

Edited 4 Years Ago by peter_budo: Moving to VB.NET

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