473,805 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[ASP] Access and Excel - preventing duplicate records

263 Contributor
Hi everyone.

With ASP I register in DB Access rows of one file excel; this procedure works but problem: Access record double rows of file excel.

You can exclude from registration double rows ?

I attach the file excel record to access.

I register with this logic:

1) all rows;
2) where rows no data register date of today;
3) if same row with a date and the other undated eliminate row undate.

Register rows excel file number: 1, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14
Discard rows 2, 3 and 5
In the field date rows 6, 7, 8, 9, 10, 11, 12, 13, 14 record date of today.

Expand|Select|Wrap|Line Numbers
  1. <!--#include virtual="/include/ConnMySQL.asp"-->
  2.  
  3. <%
  4.  
  5.   Set Rs = Server.CreateObject("ADODB.Recordset")
  6.   Rs.Open "SELECT DISTINCT * from [Foglio1$]", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("/public/UploadFolder/Book-2.xls")&";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
  7.  
  8. Do Until Rs.Eof 
  9.  
  10. if IsDate(Rs("DATA")) then
  11. strData = formatDBDate(Rs("DATA"), "mysql")
  12.  
  13.    strSql = "INSERT INTO Tabella (F1, F2, DataF3) VALUES ( " & Rs("f1") & ", '" & Rs("f2") & "', " & strData & ") "
  14.  
  15. else
  16. strData = formatDBDate(Date(), "mysql")
  17.  
  18.    strSql = "INSERT INTO Tabella (F1, F2, DataF3) VALUES ( " & Rs("f1") & ", '" & Rs("f2") & "', " & strData & ") "
  19. end if  
  20. objconn.execute(strSql)
  21.  
  22. response.write strSQL &"<br />"
  23.  
  24.     Rs.MoveNext   
  25.     Loop
  26.  
  27.  
  28.   Rs.close()    
  29.   set Rs = nothing  
  30.  
  31.   objconn.Close()
  32.   Set objconn = Nothing 
  33.  
  34. %>
  35.  
Help please.
Viki1967
Attached Images
 
Mar 9 '08 #1
4 2252
jhardman
3,406 Recognized Expert Specialist
Sorry, I had a hard time trying to understand what your question is. Are you still looking for a solution?

Jared
Mar 18 '08 #2
viki1967
263 Contributor
Yes, I looking for a method to ensure duplicate rows are not inserted in the table Access:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 333, 'CCC', '2008-03-06') ==> YES
  2. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 333, 'CCC', '2008-03-11') ==> YES
  3. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 333, 'CCC', '2008-03-11') ==> NO
  4. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 334, 'CCC', '2008-03-06') ==> YES
  5. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 334, 'CCC', '2008-03-11') ==> YES
  6. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 335, 'CCC', '2008-03-11') ==> YES
  7. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 336, 'CCC', '2008-03-11') ==> YES 
  8. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 337, 'CCC', '2008-03-11') ==> YES
  9. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 338, 'CCC', '2008-03-11') ==> YES
  10. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 339, 'CCC', '2008-03-11') ==> YES
  11. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 340, 'CCC', '2008-03-11') ==> YES
  12. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 341, 'CCC', '2008-03-11') ==> YES
  13. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 342, 'CCC', '2008-03-11') ==> YES
  14. INSERT INTO Tabella (F1, F2, DataF3) VALUES ( 343, 'CCC', '2008-03-11') ==> YES 
  15.  
Regards,
viki
Mar 19 '08 #3
jhardman
3,406 Recognized Expert Specialist
The easiest method I have found to not duplicate records is to search for the record I am looking for:
Expand|Select|Wrap|Line Numbers
  1. Query = "Select * FROM Tabella WHERE F1 = 333 AND F2 = 'CCC' AND DataF3 = '2008-03-06'"
  2. objRS.open query, objConn, adOpenDynamic, adLockOptimistic
  3.  
  4. if objRS.eof then 'no matching record was found, so I need to add it
  5.    objRS.addNew
  6.    objRS("F1") = 333
  7.    objRS("F2") = "CCC"
  8.    objRS("DataF3") = "2008-03-06"
  9.    objRS.update
  10. else 'record was found
  11.    response.write "This record is already in the db"
  12. end if
Does this make sense?

Jared
Mar 19 '08 #4
viki1967
263 Contributor
Many thanks, I don't have it any problem:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <!--#include virtual="/include/ConnMySQL.asp"-->
  3.  
  4. <%
  5.  
  6.   Set Rs = Server.CreateObject("ADODB.Recordset")
  7.   Rs.Open "SELECT * FROM [Foglio1$]","Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("/public/UploadFolder/Book-2.xls")&";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
  8.  
  9. Do Until Rs.Eof
  10.  
  11. if IsDate(Rs("Data")) then
  12.    strData = formatDBDate(Rs("Data"), "mysql")
  13. else
  14.    strData = formatDBDate(Date(), "mysql")
  15. end if
  16.  
  17. Query = " SELECT * FROM Tabella WHERE F1 = " & Rs("F1") & " AND F2 = '" & Rs("F2") & "' AND DataF3 = " & strData & " "
  18. Set objRS = Server.CreateObject("ADODB.Recordset")
  19. objRS.open Query, objconn
  20.  
  21. response.write Query & "<br><br>"
  22.  
  23. if objRS.eof then
  24.    strSql = "INSERT INTO Tabella (F1, F2, DataF3) VALUES ( " & Rs("f1") & ", '" & Rs("f2") & "', " & strData & ") "
  25.    objconn.execute(strSql)
  26.    response.write strSQL &"<br />"
  27.  
  28. else
  29.    response.write "This record is already in the db"
  30.  
  31. end if
  32.  
  33.   objRS.close()    
  34.   set objRS = nothing 
  35.  
  36.   Rs.MoveNext   
  37.   Loop
  38.  
  39.   Rs.close()    
  40.   set Rs = nothing  
  41.  
  42.   objconn.Close()
  43.   Set objconn = Nothing 
  44.  
  45. %>
  46.  
  47.  
Mar 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1208
by: Johno | last post by:
Hi Is there an easy way to enter lots of duplicate data in Access, like you can in Excel by just clicking and dragging? I have various fields that require the same data for each record and I can only find reference to repeating whats in the previous field when trying to duplicate data. Is there a quick way to enter the same data into a particular field for many records? Thanks Johno
13
3253
by: Arno R | last post by:
Hi all, I will have to handle a lot of really 'nice' data in a LOT of Excel sheets. It is all about music files (Billboard top 100) I am afraid there really is a sheet for every year ... (Don't know this for sure yet...) I definitely need to get this data in Access and get it normalized. (sigh ....) The data is so 'nice' for the Import- and TransferSpreadsheet-wizard that the 'wizard' really chokes on it ;-) Either the data is not...
24
14421
by: cassetti | last post by:
Here's the issue: I have roughly 20 MS excel spreadsheets, each row contains a record. These records were hand entered by people in call centers. The problem is, there can and are duplicate phone numbers, and emails and addresses even person names. I need to sift through all this data (roughly 300,000+ records and use fuzzy logic to break it down, so that i have only unique records.
4
6068
by: Jules48 | last post by:
I store comprehensive details of customers' "transactions" in Access (2000). At the moment, I (or my staff) duplicate entry of the information in an Excel spreadsheet which we use to extract stats and charts and to number crunch etc. Obviously, duplicating the data entry is onerous and open to error. What I'd like to do is enter the data into the Access database then use a query to compile a recordset of the latest set of records and then...
16
2981
by: RichardP | last post by:
Hi there everyone - I'm new to this forum. I am having an issue when running an application from an instance of Access which has been started through automation (early or late bound, makes no difference). No warning / confirmation messages are issued (eg. when running action queries, deleting records from a datasheet, deleting database objects such as tables).
6
11907
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks again, which created duplicate forcm submission and hence duplicate records. So I am trying to disable the button as soon as it is clicked, and as soon as it's done,
5
5198
by: Hokiecow | last post by:
I'm trying to import specific columns from an excel file (Requirements.xls) into an access table (tblRequirements). Using VBA, I'm able to import the entire excel file into table (tblImportRequirements). Instead of going row by row of (tblImportRequirements) and copying the fields needs to (tblRequirements) it would be faster to just copy the column and over write the other table's column. I'm not sure how to copy a few columns from...
1
2002
by: Charlotte | last post by:
Hallo, Graag hulp, want ik heb zelf geen oplossing Al gegoogeld, doch zonder concreet resultaat Op onze webserver (intranet) hebben we een website draaien Een bepaalde ASP-pagina haalt zijn data uit een MDB De mdb wordt gevoed door andere asp-pagina's Tot hier geen probleem
3
8828
by: khoward | last post by:
Hi, I have an Access 2007 database that contains customer contact information. There are over 8,000 that include name, organization (as a look-up column), email, phone, address, and events that each person should be invited to (also a look-up column). Separate from this is an Excel spreadsheet that contains the some of the same information, with about 10,000 records. The overlap with duplicate names/records is probably about 50%, but of...
0
10363
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
10368
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
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
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
7649
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
6876
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();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
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.