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:\Users\dell\Documents\Visual Studio 2005\Projects\CollectionAndBilling\Resources.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