|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to have Insert or Select Statement NOT allow Duplicatesfollowing 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.AcceptChanges() For Each rowX As DataRow In DataSet1.Lot_Tracking_Hist.Rows sSQL = "INSERT INTO [LotTrackingHistory] (LOTNUM_72, TNXDTE_72, PRTNUM_72, USRNAM_72," & _ "STKID_72, TNXQTY_72, ORDNUM_72, UDFREF_72)" & _ " Values " & _ "('" & rowX.Item("LOTNUM_72").ToString & "'," & _ "#" & rowX.Item("TNXDTE_72") & "#," & _ "'" & rowX.Item("PRTNUM_72").ToString & "'," & _ "'" & rowX.Item("USRNAM_72").ToString & "'," & _ "'" & rowX.Item("STKID_72").ToString & "'," & _ "'" & rowX.Item("TNXQTY_72").ToString & "'," & _ "'" & rowX.Item("ORDNUM_72").ToString & "'," & _ "'" & rowX.Item("UDFREF_72").ToString & "')" With objCommand ' this portion identifies the connection that will supply the data to be entered duing the commands .Connection = oOleDbConnection .CommandText = sSQL .CommandType = CommandType.Text .ExecuteNonQuery() 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") oOleDbConnection.Close() ' data is completed and time to close the ole connection oOleDbConnection = Nothing Catch ex As Exception MessageBox.Show(ex.ToString) End Try "rickn" <ricknichol***@att.net> wrote in message Set LOTNUM_72 as a key: must be unique / no duplicates allowed. It need not news:1144509094.951244.168370@t31g2000cwb.googlegroups.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. be primary.
StringBuilder termination char
Run code from IDE Save graphics image to bitmap? 32bit image quality in menus and tool bar strips VB2005 - Secure Access to SQL Server through Application Only Applications sharing Forms Authentication OptionExplicit How can I know my application's path? decimal serious problem mousehover |
|||||||||||||||||||||||