CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 How to check duplicate value before Insert ||Urgent||

Print topic Send  topic

Author Message
girish_327


Posts: 108
Posted: 05/31/2004, 12:02 AM

Hi,
Please help me checking duplicate values in table before insert
Table Fields :-
rare_id, ebook_id, user_id, rate, ip
I want check ebook_id and ip fieds if these fieilds are already in database then must say "Duplicate Value"

Please tell me how can i solve this problem.

Thank you


_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message
peterr


Posts: 5971
Posted: 05/31/2004, 5:39 AM

Usually the "Unique" property should take care of it. Please set it to "Yes" and see if this works the way you'd like.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
girish
Posted: 05/31/2004, 8:12 AM

Its Right when only checking single field but I want check
IP field and ebook_id field these both fields if equals then only i want display error msg.
peterr


Posts: 5971
Posted: 05/31/2004, 5:53 PM

In this case take a look at the validation examples in the docs:
http://docs.codecharge.com/studio/html/ProgrammingTechn...Validation.html
http://docs.codecharge.com/studio/html/ProgrammingTechn...Validation.html

I believe that you would need to use the CCDLookup function in form validation to check if a record with both such fields already exists. Here is an example of looking up values: http://docs.codecharge.com/studio/html/ProgrammingTechn...gleDBValue.html
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
girish_327


Posts: 108
Posted: 06/02/2004, 9:49 AM

Thank You Very much Peter R.
if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id=" &  CCToSQL(CCGetUserID(),"Integer"),DBebook) then 

But Its not working when I am Checking ebook_id with IP address.
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message
girish_327


Posts: 108
Posted: 06/02/2004, 9:51 AM

if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id=" &  CCToSQL(CCGetUserID(),"Integer"),DBebook) then  
  if rating.user_id.value = CCDLookup("user_id","rating","user_id=" &  CCToSQL(CCGetUserID(),"Integer"),DBebook) then  
    rating.Errors.addError("You Can't Rate Same eBook Twice.")  
  end if  
end if

_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com
View profile  Send private message
peterr


Posts: 5971
Posted: 06/02/2004, 10:45 AM

You can do this with one lookup, for example:
if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id=" & CCToSQL(CCGetUserID(),"Integer") & " AND ip=" & Request.ServerVariables("REMOTE_ADDR"), DBebook)

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
sappie

Posts: 13
Posted: 12/29/2004, 6:32 AM

Quote peterr:
You can do this with one lookup, for example:
if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id=" & CCToSQL(CCGetUserID(),"Integer") & " AND ip=" & Request.ServerVariables("REMOTE_ADDR"), DBebook)


If I use this (modified) lookup function I keep getting errors.
The function I use is:
***
ESF_Cursus.Voorstel_Id.value = CCDLookUp("max(Voorstel_Id)", "Voorsteller","Logonusr=" & Request.ServerVariables("REMOTE_USER"), DBESF)
***
The error I get is:
****
Source: CCDLookUp function
Command Text: SELECT max(Voorstel_Id) FROM Voorsteller WHERE Logonusr=domain\user
Error description: No value given for one or more required parameters. (Microsoft JET Database Engine)<
****
Can someone please tell me what wrong?
View profile  Send private message
peterr


Posts: 5971
Posted: 12/29/2004, 12:18 PM

This is a different issue. Please try not to mix unrelated topics, even if you use the same function. You can probably run that SQL query in your database to examine why it doesn't work.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Don Safar
Posted: 12/29/2004, 12:57 PM

Try this
ESF_Cursus.Voorstel_Id.value = CCDLookUp("max(Voorstel_Id)",
"Voorsteller","Logonusr= ' " & Request.ServerVariables("REMOTE_USER") & " '
", DBESF)

I added single quote so it should be
SELECT max(Voorstel_Id) FROM Voorsteller WHERE Logonusr='domain\user'

"sappie" <sappie@forum.codecharge> wrote in message
news:641d2bfff97f5f@news.codecharge.com...
>
Quote peterr:
> You can do this with one lookup, for example:
>
if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id="   
> &  
> CCToSQL(CCGetUserID(),"Integer") & " AND ip=" &  
> Request.ServerVariables("REMOTE_ADDR"), DBebook)
>
>
>
> If I use this (modified) lookup function I keep getting errors.
> The function I use is:
> ***
> ESF_Cursus.Voorstel_Id.value = CCDLookUp("max(Voorstel_Id)",
> "Voorsteller","Logonusr=" & Request.ServerVariables("REMOTE_USER"), DBESF)
> ***
> The error I get is:
> ****
> Source: CCDLookUp function
> Command Text: SELECT max(Voorstel_Id) FROM Voorsteller WHERE
> Logonusr=domain\user
> Error description: No value given for one or more required parameters.
> (Microsoft JET Database Engine)<
> ****
> Can someone please tell me what wrong?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

sappie

Posts: 13
Posted: 12/31/2004, 2:06 AM

Perfect! Thank you!

Quote Don Safar:
Try this
ESF_Cursus.Voorstel_Id.value = CCDLookUp("max(Voorstel_Id)",
"Voorsteller","Logonusr= ' " & Request.ServerVariables("REMOTE_USER") & " '
", DBESF)

I added single quote so it should be
SELECT max(Voorstel_Id) FROM Voorsteller WHERE Logonusr='domain\user'

"sappie" <sappie@forum.codecharge> wrote in message
news:641d2bfff97f5f@news.codecharge.com...
>
Quote peterr:
> You can do this with one lookup, for example:
>
if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id="   
> &  
> CCToSQL(CCGetUserID(),"Integer") & " AND ip=" &  
> Request.ServerVariables("REMOTE_ADDR"), DBebook)
>
>
>
> If I use this (modified) lookup function I keep getting errors.
> The function I use is:
> ***
> ESF_Cursus.Voorstel_Id.value = CCDLookUp("max(Voorstel_Id)",
> "Voorsteller","Logonusr=" & Request.ServerVariables("REMOTE_USER"), DBESF)
> ***
> The error I get is:
> ****
> Source: CCDLookUp function
> Command Text: SELECT max(Voorstel_Id) FROM Voorsteller WHERE
> Logonusr=domain\user
> Error description: No value given for one or more required parameters.
> (Microsoft JET Database Engine)<
> ****
> Can someone please tell me what wrong?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


View profile  Send private message
lhchua
Posted: 01/23/2005, 11:41 PM

hi,

i wld like to create a trigger.. my condition is before i insert, i need to check if some field exists. if it exist, i delete the records, else i insert.

i want to ask, can it be done as i know that "before insert" assume there is no existing records in the table. so how can i use "before insert"..

what shld i use? can anyone kindly advise.. many thanks.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.