How can i know that if there is required record in the Database(SQL) in ASP page.Will recordset.Recordcount work for it?I think it will show only the total number of records in the Database.
How can i know that the specific record exists in the Database in ASP?
I have used SELECT IF EXISTS in my SQL statement before, but I couldn't find a good example.
See the souce page below that checks for rs.EOF to see if there are any records returned after a regular SELECT statement.
Good Luck!
Reply:In order to see if a specific record exists, you need to know what it is about it that makes it specific. For example, if you are looking for all customers with a balance greater than $1,000, all students from PA,, or a client with the last name of "Orloski"
Looking for specific records is what SQL is for. I highly suggest you do some reading about it.
Reply:SQL = "
SELECT
count(some_field) as cntr
FROM
some_table
WHERE
unique_field = x
If cntr =0 then
' not found'
else
' found'
end if
Now wrap that into .ASP recordset code and you have it. You will ALWAYS only get 1 record back so it saves a bunch of testing for null's etc.
I am sure you have plenty of SQL recordset code to copy from, so I just gave you the SQL.
Have fun.
Reply:lets take a imaginary case where the record you want has first_name like "mervin" and pin_code like 560092
select * from table_name where first_name like 'mervin' and pin_code=560092
i hope this answers your query
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment