473,785 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to have Insert or Select Statement NOT allow Duplicates

Being new to VB and programming, I'm not sure how to modify the
following or if required have a Select statement to NOT allow any
duplicates. I'm trying not to have any duplicates in the LOTNUM_72
field. The data is coming from odbc and being inserted via ole into
access. IF the LOTNUM_72 field is set as Prinary Key, then no records
are inserted if any duplicates are seen.

I'n not sure at all how to make the coding so if a duplicate does exist
it is not entered and the remaining data is.

icount = 0 'set the value to count the number of tickets
DataSet1.Accept Changes()
For Each rowX As DataRow In DataSet1.Lot_Tr acking_Hist.Row s
sSQL = "INSERT INTO [LotTrackingHist ory] (LOTNUM_72,
TNXDTE_72, PRTNUM_72, USRNAM_72," & _
"STKID_72,
TNXQTY_72, ORDNUM_72, UDFREF_72)" & _
" Values " & _
"('" & rowX.Item("LOTN UM_72").ToStrin g & "'," & _
"#" & rowX.Item("TNXD TE_72") & "#," & _
"'" & rowX.Item("PRTN UM_72").ToStrin g & "'," & _
"'" & rowX.Item("USRN AM_72").ToStrin g & "'," & _
"'" & rowX.Item("STKI D_72").ToString & "'," & _
"'" & rowX.Item("TNXQ TY_72").ToStrin g & "'," & _
"'" & rowX.Item("ORDN UM_72").ToStrin g & "'," & _
"'" & rowX.Item("UDFR EF_72").ToStrin g & "')"

With objCommand ' this portion identifies the
connection that will supply the data to be entered duing the commands
.Connection = oOleDbConnectio n
.CommandText = sSQL
.CommandType = CommandType.Tex t
.ExecuteNonQuer y()
End With
'Count the number of entries and display them. Lets
create a message box and display the results of data entered
icount += 1 'total number of tickets processed

Next
MessageBox.Show (icount, "Total Number Tickets Entered In
Lab Table") 'Total Tickets Entered in Lab Table
' If icount > 1 Then MessageBox.Show (icount, "No Tickets
Entered")
oOleDbConnectio n.Close() ' data is completed and time to
close the ole connection
oOleDbConnectio n = Nothing
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try

Apr 8 '06 #1
1 1658

"rickn" <ri***********@ att.net> wrote in message
news:11******** **************@ t31g2000cwb.goo glegroups.com.. .
Being new to VB and programming, I'm not sure how to modify the
following or if required have a Select statement to NOT allow any
duplicates. I'm trying not to have any duplicates in the LOTNUM_72
field. The data is coming from odbc and being inserted via ole into
access. IF the LOTNUM_72 field is set as Prinary Key, then no records
are inserted if any duplicates are seen.


Set LOTNUM_72 as a key: must be unique / no duplicates allowed. It need not
be primary.

Apr 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3948
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
1
34775
by: Thomas Bartkus | last post by:
The meaning of REPLACE INTO is clear to me. IF the new record presents new key values, then it is inserted as a new record. IF the new record has key values that match a pre-existing record, then the key violation is ignored and the new record *replaces* the pre-existing record. But what about INSERT IGNORE? Is this a synonym for REPLACE INTO - i.e. it does precisely the same thing?
5
7504
by: ratu | last post by:
I'd like to use a stored procedure to insert large amounts of records into a table. My field A should be filled with a given range of numbers. I do the following ... but I'm sure there is a better (faster) way: select @start = max(A) from tbl where B = 'test1' and C = 'test2' while @start <= 500000 begin insert into tbl (A, B, C) values (@start, 'test1', test2')
20
8581
by: akej via SQLMonster.com | last post by:
Hi, i have table with 15 columns CREATE TABLE . ( PRIMARY KEY , NULL , NULL , NULL , NULL , (50) NULL , NULL
6
12358
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of 10 columns into a table with 12. How can I specify which columns to insert to? I think format files are what I'm supposed to use, but I can't figure them out. I've also tried using a view, as was suggested on one of the many websites I've...
1
2038
by: mike | last post by:
Hello all, any advice or links to pages about how to have multiple language asp pages? For example, you have a database driven website that you want customers around the world to use. How do you setup the asp pages so that it is easy to change the text based on where the user is connecting from? Thanks, Mike
3
14009
by: shorti | last post by:
I am looking for a way to insert into one table from another table but ignore duplicates (because the query will fail since the column I am inserting into is a unique index). RE: INSERT INTO table1 (SELECT column1 from table2) This query works if table1 is empty but if table1 has any recorda they would be duplicate to table2. I also cannot delete the existing
1
15510
by: cefrancke | last post by:
I'm trying to insert records in a table that has a "no duplicates" index on two columns. The following snippet shows where I started off... INSERT INTO Table_A (ID_A, ID_B) VALUES (334, 2057) However, if these two values exist already as a "key" combination then, the MS Access
2
9433
by: rn5a | last post by:
In a ASP applicatiuon, the FOrm has a textbox & a select list where the admin can select multiple options. Basically the admin has to enter the name of a new coach in the textbox & select the soccer clubs which he will be coaching; thus he can select only one soccer club for a new coach or multiple soccer clubs. This is how I am trying it: When this Form will be submitted, the new coaches name will be inserted in a MS-Access DB table...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.