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

can you save the data to the database but dont close the software yet,,
confirm that the data is actually written to the database,,

get back to me that the data is actually there

ok i have a saved a few data, i didn't close the software yet and it's there in the database. does this means that whenever i close the software the data will be removed? and what exactly do you mean by don't close the software? leave the program still running/debugging? or just don't close vb2008?

anyway thx for ur time

k,, so this means that your either loosing the data on close or re-opening it,

so,, now what i want you to do is close the software and check the database to see
if the data is still in there.

tell me if it is or not

Edited 6 Years Ago by marketingmaniac: n/a

Sophisticated, I have asked that your post be moved to .Net, this is the VB6 forum. I'm sure you will find your answer there, good luck

When you declare the data adapter, you only fill in the SELECT Command.

In order the data adapter can modify the data base contents, you need also to define the Insert, Delete and Update commands for the da on FormElectricalWorkshopCertNew_Load, before isuuing the da.Update(dt) in butCont2_Click.

Hope this helps

Edited 6 Years Ago by lolafuertes: n/a

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