|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
What I want to know is how do you check if a record exists in a MSSQL database. When a user visits a page in my ASP app it picks up thier username and uses it later on in the app. What I want to know is how do I say in asp and sql , do I have a record in my database for user "john smith"? Then I can shoose my next action according to weather or not the user exists. Make sense?
I know how to query SQl from ASP but How do I work out if the query came back with no resaults. So say I inject Code:
select username from mytable where username ='john smith' How would I check with asp that it didnt not return any resaults? Any one have any ideas? Thanks in advance |
|
#2
|
|||
|
|||
|
select count(*) as dotheyexist from mytable where username = 'john smith'
if the value of dotheyexist != 0 then they do exist. |
|
#3
|
|||
|
|||
|
If you select into an ado recordset, both eof and bof will be true if the recordset is empty.
rs.open "select * from wherever", con if rs.bof and rs.eof then response.write "nothing in the rs" else response.write "there was data returned" end if |
|
#4
|
|||
|
|||
|
Thanks doug that worked perfect
|
|
#5
|
|||
|
|||
|
You're welcome!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Find out if a record exists, ASP,MSSQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|