3 Replies - 380 Views - Last Post: 30 January 2013 - 10:12 PM Rate Topic: -----

#1 Guitora Kuronato  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 28
  • Joined: 02-December 12

Reopen program then data base data gone, is there any problem?

Posted 30 January 2013 - 07:37 PM

Hello, now i was making a notif form. I had try it with my best.
The problem is,, while i save the input data, without close the program, i open the database and the data went out..
But after i close the program and reopen again. All the data of database gone..
At my code, there are not having any error.
Can anyone tell what is the problem?
my database is using access 2010
this is my save code
 Dim q As MsgBoxResult
        If EMP_NOTextBox.Text = "" Or EMP_NAMETextBox.Text = "" Or POSITIONTextBox.Text = "" Or REASONSTextBox.Text = "" _
            Or APP_MAILTextBox.Text = "" Or APP_OWNTextBox.Text = "" Or APP_DATETextBox.Enabled = False And APP_TIMETextBox.Enabled = False Then
            MsgBox("Please fill all the data")
        Else
            q = MsgBox("Are you sure the data had correct?", vbQuestion + vbYesNo, "Apply")
            If q = vbYes Then
                Try
                    Try
                        con = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\notifdb.accdb")
                        con.Open()
                        Dim command As String
                        command = "INSERT INTO NFTB (NOTIF, EMP_NO, EMP_NAME, [POSITION], APP_DATE, APP_DT_FROM, APP_DT_TO, APP_TIME, APP_TIME_FROM, APP_TIME_ON, REASONS, REMARKS, TIME_IN, TIME_OUT, CHECKED_IN, CHECKED_OUT, IN_ON, OUT_ON, APP, APP_MAIL, APP_OWN) VALUES (@NOTIF, @EMP_NO, @EMP_NAME, @POSITION, @APP_DATE, @APP_DT_FROM, @APP_DT_TO, @APP_TIME, @APP_TIME_FROM, @APP_TIME_ON, @REASONS, @REMARKS, @TIME_IN, @TIME_OUT, @CHECKED_IN, @CHECKED_OUT, @IN_ON, @OUT_ON, @APP, @APP_MAIL, @APP_OWN)"
                        Dim cmd As OleDbCommand
                        cmd = New OleDbCommand(command, con)
                        cmd.Parameters.AddWithValue("@NOTIF", NOTIFTextBox.Text)
                        cmd.Parameters.AddWithValue("@EMP_NO", EMP_NOTextBox.Text)
                        cmd.Parameters.AddWithValue("@EMP_NAME", EMP_NAMETextBox.Text)
                        cmd.Parameters.AddWithValue("@POSITION", POSITIONTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_DATE", APP_DATETextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_DT_FROM", APP_DT_FROMTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_DT_TO", APP_DT_TOTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_TIME", APP_TIMETextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_TIME_FROM", APP_TIME_FROMTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_TIME_ON", APP_TIME_ONTextBox.Text)
                        cmd.Parameters.AddWithValue("@REASONS", REASONSTextBox.Text)
                        cmd.Parameters.AddWithValue("@REMARKS", REMARKSTextBox.Text)
                        cmd.Parameters.AddWithValue("@TIME_IN", TIME_INTextBox.Text)
                        cmd.Parameters.AddWithValue("@TIME_OUT", TIME_OUTTextBox.Text)
                        cmd.Parameters.AddWithValue("@CHECKED_IN", CHECKED_INTextBox.Text)
                        cmd.Parameters.AddWithValue("@CHECKED_OUT", CHECKED_OUTTextBox.Text)
                        cmd.Parameters.AddWithValue("@IN_ON", IN_ONTextBox.Text)
                        cmd.Parameters.AddWithValue("@OUT_ON", OUT_ONTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP", APPTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_MAIL", APP_MAILTextBox.Text)
                        cmd.Parameters.AddWithValue("@APP_OWN", APP_OWNTextBox.Text)
                        cmd.ExecuteNonQuery()
                    Catch exceptionObject As Exception
                        MessageBox.Show(exceptionObject.Message)
                    Finally
                        con.Close()
                    End Try
                Catch exceptionObject As Exception
                    MessageBox.Show(exceptionObject.Message)
                Finally
                    con.Close()
                End Try
                Dim oout As Object
                Dim omsg As Object

                oout = CreateObject("Outlook.Application")
                omsg = oout.CreateItem(0)

                With omsg
                    .To = APP_MAILTextBox.Text
                    .CC = "arwin.kasnady@ymb.yokogawa.com"
                    .Subject = "Notification Form"
                    .Body = "Hello Sir/Madam, my notification no is " + S_NTextBox.Text

                    .send()
                End With
                oout = Nothing
                omsg = Nothing
                Me.Validate()
                Me.NFTBBindingSource.EndEdit()
                Me.TableAdapterManager.UpdateAll(Me.NotifdbDataSet)
                MsgBox("Your form number is " + S_NTextBox.Text)
                DateTimePicker1.Visible = False
                DateTimePicker2.Visible = False
                DateTimePicker3.Visible = False
                GroupBox3.Enabled = False
                GroupBox4.Enabled = False
                MsgBox("Please click the save button above to complete this form")
            Else
            End If
        End If


and this is my load form code
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Enabled = False
        REMARKSTextBox.Enabled = False
        APP_DATETextBox.Enabled = False
        APP_DT_FROMTextBox.Enabled = False
        APP_DT_TOTextBox.Enabled = False
        APP_TIME_FROMTextBox.Enabled = False
        APP_TIME_ONTextBox.Enabled = False
        APP_TIMETextBox.Enabled = False
        DateTimePicker1.Visible = False
        DateTimePicker2.Visible = False
        DateTimePicker3.Visible = False
        NOTIFTextBox.Visible = True
        GroupBox3.Enabled = False
        GroupBox4.Enabled = False
        Dim con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\USERID.accdb;Persist Security Info=True;Jet OLEDB:Database Password=112233")
        Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT [S/N], NOTIF, EMP_NO, EMP_NAME, [POSITION], APP_DATE, APP_DT_FROM, APP_DT_TO, APP_TIME, APP_TIME_FROM, APP_TIME_ON, REASONS, REMARKS, TIME_IN, TIME_OUT, CHECKED_IN, CHECKED_OUT, IN_ON, OUT_ON, APP, APP_MAIL, APP_OWN FROM NFTB WHERE [S/N] = '" & S_NTextBox.Text & "' AND NOTIF = '" & NOTIFTextBox.Text & "'AND EMP_NO = '" & EMP_NOTextBox.Text & "' AND EMP_NAME = '" & EMP_NAMETextBox.Text & "' AND [POSITION] = '" & POSITIONTextBox.Text & "' AND APP_DATE = '" & APP_DATETextBox.Text & "'AND APP_DT_FROM = '" & APP_DT_FROMTextBox.Text & "' AND APP_DT_TO = '" & APP_DT_TOTextBox.Text & "' AND APP_TIME = '" & APP_TIMETextBox.Text & "' AND APP_TIME_FROM = '" & APP_TIME_FROMTextBox.Text & "' AND APP_TIME_ON = '" & APP_TIME_ONTextBox.Text & "' AND REASONS = '" & REASONSTextBox.Text & "' AND REMARKS = '" & REMARKSTextBox.Text & "' AND TIME_IN = '" & TIME_INTextBox.Text & "' AND TIME_OUT = '" & TIME_OUTTextBox.Text & "' AND CHECKED_IN = '" & CHECKED_INTextBox.Text & "' AND CHECKED_OUT = '" & CHECKED_OUTTextBox.Text & "' AND IN_ON = '" & IN_ONTextBox.Text & "' AND OUT_ON = '" & OUT_ONTextBox.Text & "' AND APP = '" & APPTextBox.Text & "' AND APP_MAIL = '" & APP_MAILTextBox.Text & "' AND APP_OWN = '" & APP_OWNTextBox.Text & "'", con)
        con.Open()

    End Sub


Please give me an advice, cause i'm just new at vs2012

Is This A Good Question/Topic? 0
  • +

Replies To: Reopen program then data base data gone, is there any problem?

#2 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,083
  • Joined: 02-July 08

Re: Reopen program then data base data gone, is there any problem?

Posted 30 January 2013 - 08:53 PM

I don't understand your form load sub - your query is trying to filter based on all the data in the textboxes - which should be empty on form load right? Are you thinking this would fill them? The Where clause is used to filter incoming data and is typical to have it filter on a few fields, but not the entire field collection as would only return one record if it matched all fields. Tell us more about what your wanting to data to do.
Was This Post Helpful? 0
  • +
  • -

#3 Guitora Kuronato  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 28
  • Joined: 02-December 12

Re: Reopen program then data base data gone, is there any problem?

Posted 30 January 2013 - 09:25 PM

I had solve it my self, it just code crash problem..

Actually i just wanted to save to my database and when i open the program, it can show the data.
Just like student record.
But the problem now is, when i had save, it actually save. but when i close and start the project again, all the data gone.


Thanks for your reply Hawk.. how can i close this topic?
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,083
  • Joined: 02-July 08

Re: Reopen program then data base data gone, is there any problem?

Posted 30 January 2013 - 10:12 PM

You can't. Solutions are here for others to search - if people place their solutions to their problems.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1