hello pls help me how to solve this matter? pls? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

hello pls help me how to solve this matter? pls?

mamonizemamonize Posts: 3Member
i am a beginner programmer and i have some problem regarding with avoiding data duplication, based on the Sales invoice no. this is sample of my codes.


Imports System.Data.OleDb


Public Class Form1
Dim SconT As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersdellDocumentsVisual Studio 2005ProjectsCollectionAndBillingResources.accdb")
Dim SConTole As New OleDbConnection(SconT)
Dim ConS As String


Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

Try

SConTole.Open()

Dim Command As New OleDbCommand(ConS, SConTole)
Dim dr As OleDbDataReader = Command.ExecuteScalar()

While dr.Read()
If dr.Item("SalesInv") <> txtBillingNumber.Text Then

ConS = "Insert Into InData([CoName],[Reciever],[BldgName],[CoAddrss],[SalesInv],[RefNo],[FileDate],[Position],[PayRefNo],[PeriodCA],[PBAASF],[VAT],[Total],[SubTotal],[TAmount])" & " Values ('" & txtClientName.Text & "','" & TextReciever.Text & "','" & txtArea.Text & "','" & txtAddress.Text & "','" & txtBillingNumber.Text & "','" & txtContactRefNo.Text & _
"','" & DTPFile.Text & "','" & txtCC.Text & "','" & txtPayrollReference.Text & " ','" & txtPeriod.Text & "','" & txtPaBeAllASF.Text & "','" & txtVAT.Text & "','" & txtTotal1.Text & "','" & txtTotal2.Text & "','" & txtTotalAmount.Text & "')"


Command.ExecuteNonQuery()
MsgBox("Data has been added.", MsgBoxStyle.Information)

Else
MsgBox("Data already exist.")

End If
End While

SConTole.Close()

Catch ex As Exception
MsgBox("Cannot Process.")
End Try


SConTole.Close()

End Sub
End Class
Sign In or Register to comment.