Hi
I 'm trying to develop a database whereby all information input via vb 2008 will be saved into a microsoft access database. I've tried to populate a few information. The data was saved at that point, but when i reopen my system the next day, all the rows are gone. This problem has been happening for quite some time n i couldnt figure out why.
Help needed!
Thanx.
Here is my coding
Public Class FormElectricalWorkshopCertNew
Private conn As New OleDb.OleDbConnection()
Private da As OleDb.OleDbDataAdapter
Private cb As OleDb.OleDbCommandBuilder
Private dt As New DataTable
Private rowindex As Integer = 0
Private Sub FormElectricalWorkshopCertNew_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
conn.Close()
conn.Dispose()
End Sub
Private Sub FormElectricalWorkshopCertNew_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn.ConnectionString = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\user\Contacts\Documents\Visual Studio 2008\Projects\MLNG Active Database v1\MLNG Active Database v1\bin\Debug\Database.mdb"
conn.Open()
da = New OleDb.OleDbDataAdapter("Select * From MotorTable", conn)
cb = New OleDb.OleDbCommandBuilder(da)
da.Fill(dt)
End Sub
Private Sub butCont2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butCont2.Click
Dim dr As DataRow = dt.NewRow()
Dim dgrResult As DialogResult
Dim strMessage As String
strMessage = "Are you sure you want to proceed?"
dgrResult = MessageBox.Show(strMessage, "Save Motor Details", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2)
If dgrResult = DialogResult.Yes Then
dr("Tag_No") = txtTagNoNew.Text
dr("Serial_No") = txtSerialNoNew.Text
dr("Manufacturers") = txtManufacturerNew.Text
dr("EXType") = txtEXTypeNew.Text
dr("RatingKW") = txtRatingNew.Text
dr("Voltage") = txtVoltageNew.Text
dr("Faults_Defect") = txtFaultsNew.Text
dr("Location_Area") = cboArea.Text
dr("Start_Date") = StartDate.Value
dr("Expected_Completion_Date") = ExpectedCompletionDate.Value
dr("Work_Type") = cboWorkType.Text
dt.Rows.Add(dr)
da.Update(dt)
rowindex = dt.Rows.Count - 1
End If
End Sub
End Class