Add data using vb+access

Submitted by:Jhon Jhon

Date added:21 January, 2013

Category:VB.NET

VB code to add data using access

Tags: add data

Code Snippet:

    Private Sub AddData()
Dim NewRow As DataRow = frmBuildingEditor.dsBill.BILL.NewRow
Dim NewDate As String = Format(dtpDate.Value, My.Settings.DateFormat)

Try
NewRow("IssuedDate") = CStr(DateTime.ParseExact(NewDate, My.Settings.DateFormat, iCultureInfo))
NewRow("Description") = frmBuildingEditor.ValidateInput(txtDesc.Text)
NewRow("Amount") = frmBuildingEditor.ValidateInput(CDbl(txtAmount.Text))
NewRow("Status") = frmBuildingEditor.ValidateInput(cmbStatus.Text)
NewRow("LotID") = frmBuildingEditor.ValidateInput(frmBuildingEditor.lblID.Text)
Catch ex As Exception
uProceed = False
MessageBox.Show("Please check your input.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

If uProceed = True Then
Try
frmBuildingEditor.dsBill.BILL.Rows.Add(NewRow)
frmBuildingEditor.daBill.Update(frmBuildingEditor.dsBill)

MessageBox.Show("New Shop Lot successfully registered.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)

frmPersona.AddLog(String.Format("[+] Added bills [ID:{0}..]", frmBuildingEditor.dsBill.BILL.Rows(frmBuildingEditor.dsBill.BILL.Rows.Count - 1).Item(0).ToString))

frmBuildingEditor.ReloadBills()
Me.Close()

Catch ex As Exception
MessageBox.Show("Ops! There's an error occurred while adding data.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
 
 

Comments