Solved

Multiple Record Insert (Check if file exist)

Posted on 2009-07-07
5
313 Views
Last Modified: 2012-05-07
Hello all.
This is simple to do in a single record insert.
But, using a Multiple Record Insert, it is not quite working right.

So.
The code below works great for Inserting Multiple Records.

I need to check if "Any" of the records exist.  
And if "Any" do then display them to the page.
Then once the user corrects them, then insert all records.

(Hope that makes since)
Code below
<%

Set objRs1=CreateObject("ADODB.RecordSet")

getSQL1 = "SELECT ID, Email, MyFN, MyLN, Status, OrgID FROM Members"

objRs1.Open getSQL1, objConn, 1, 1, 1
 
 

Set objCommand=Server.CreateObject("ADODB.Command")

objCommand.ActiveConnection=objConn

row=CInt(Request.Form("row"))

For n=1 to row

strMyStatus = request.Form("Status_" & n)

strMyID = request.Form("MyID_" & n)

strMyFN = request.Form("FirstName_" & n)

strMyLN = request.Form("LastName_" & n)

strMyEmail = request.Form("Email_" & n)

sqlOrgInsert = "Insert into Members (MyFN, MyLN, Email, Status, OrgID, Payment, PayStatus)Values('"&strMyFN&"','"&strMyLN&"','"&strMyEmail&"','NotActive', "&GetMyOrg&", 'MemPayment', 'Yearly')"

objCommand.CommandText=sqlOrgInsert

objCommand.Execute

Next

%>

Open in new window

0
Comment
Question by:Wayne Barron
  • 3
  • 2
5 Comments
 
LVL 20

Assisted Solution

by:Gawai
Gawai earned 500 total points
ID: 24802490
before sqlOrgInsert, u can have a check
sqlCheck = "select * from <tableName> where yourData='value' "
execute that query and..
if objRs1.eof then
'insert records
else
'record exist; display error
end if
0
 
LVL 30

Author Comment

by:Wayne Barron
ID: 24803267
This does not work on a Multi-Insert.
Have already tried.

As i mentioned above, this is simple on a single record insert, you can use that IF Statement
To check, but this catches the 1 instance of a duplicate and stops the whole thing
AND if you do not have no duplicates, it still stops the whole thing.

Need something else.
Thanks fo for the try though.
I should have posted that I actually did the abvious coding prior to posting.

Carrzkiss
0
 
LVL 20

Expert Comment

by:Gawai
ID: 24805312
did u try with ajax ?
seems u need to search for multiple records before insert
0
 
LVL 30

Author Comment

by:Wayne Barron
ID: 24805895
Actually it is using AJAX to a point.
At least to let you know that it is processing.

If you know of a way to do this in AJAX completely.
Then that would be awesome.
As a lot of the site already uses AJAX. (Starting to really love AJAX) now...
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 0 total points
ID: 24875408
I have gone a different much better easier route.

Each set of Fields that are created, have their own <form>
So, each field, is submitted once that set of fields is completed.
Using something similuar to what I have coded here, but instead of inserting all the records at one time.
I am doing it indivisually.

So.
If I list 1 - set of fields -to- 100 - set of fields.
Each Set have it's own Uniquely nunmbers <form>
So, everything gets submitted perfectly and without issue.

Each record is checked to make sure that it doe not already exist, and then if does not insert.

Right sweet really.

have a good one.
Carrzkiss
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Classic ASP - cannot find folder on the server 5 31
UTC (timezone) without using an API 16 39
ASP Focus problem 3 51
Error viewing ASP page 12 148
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now