473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

[ASP] Access and Excel - preventing duplicate records

263 100+
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 2233
jhardman
3,406 Expert 2GB
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 100+
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 Expert 2GB
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 100+
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
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...
13
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...
24
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...
4
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...
16
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...
6
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...
5
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...
1
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.