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
and this is my load form code
Please give me an advice, cause i'm just new at vs2012
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