Using vbscript i am trying to add data to access database. I am successfully able to add data to database but i want to check duplicity before adding data to database.
Duplicity should check in column Name, Phone and Id if found duplicity in any of these three column then show message found duplicity.
Below is the code which help me to add data to database.
sub addUser
SQL_query = "INSERT INTO dvd (timestammp,Name,Phone,Id,Cat,StartDate,agent,amount,source,conver) VALUES ('"& txtteNow.value &"','"& txtName.value &"','"& txtPhone.value &"','"& txtId.value &"','"& txtCat.value &"','"& txtStartDate.value &"','"& txtsrch.value &"','"& txtamount.value &"','"& txtsource.value &"','"& txtconver.value &"')"
conn.Execute(SQL_query
end sub
I try below code also but not working.
SQL_query = "INSERT INTO dvd (timestammp,Name,Phone,Id,Cat,StartDate,agent,amount,source,conver) VALUES('"& txtteNow.value &"','"& txtName.value &"','"& txtPhone.value &"','"& txtId.value &"','"& txtCat.value &"','"& txtStartDate.value &"','"& txtsrch.value &"','"& txtamount.value &"','"& txtsource.value &"','"& txtconver.value &"') WHERE NOT EXISTS (Select '2' from dvd where Name = + " & txtName.value & + "
conn.Execute(SQL_query)
See Question&Answers more detail:os