record present or not

Results 1 to 3 of 3

Thread: record present or not

  1. #1
    Join Date
    Dec 1969

    Default record present or not

    Having a problem understanding why the following happens:<BR><BR>In my Access97 database, I have a "photo" field which merely contains the html &#060;img src="somepic.gif"&#062;. I want to detect if there is data in the field for a particular user, So as to allow the user to upload an image IF there is nothing already in the field under their CustID #. So, I wrote:<BR><BR>==================================== =========<BR>&#060;%<BR>(database connection ommited for brevity)<BR>sql=SELECT custID, photo WHERE custID=session("custID")<BR><BR>rs=db.execute(sql) <BR><BR>IF rs("photo")="" Then %&#062;<BR> &#060;!--include file="uploadform.html"--&#062; <BR> &#060;% else<BR> response.write("pic already in db")<BR>end if<BR>%&#062;<BR>================================= ==============<BR><BR>Problem is...I get "pic already in db" whether or not there is data in the field! ? <BR><BR>Can anyone help? thanks!<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: record present or not

    try<BR><BR>if IsNull(rs("Photo")) or rs("photo") = "" or rs("photo") = " " or or rs("photo") = " " then<BR><BR>&#060;!--include file="uploadform.html"--&#062; <BR>&#060;% else<BR>response.write("pic already in db")<BR>end if<BR>%&#062;<BR><BR>

  3. #3
    Jason Guest

    Default RE: record present or not

    a couple of things to try:<BR> 1. I use Set RS = Server.CreateObject("ADODB.Recordset")<BR> and then say, in your case, RS.Open SQL, db, 1, 3<BR> I didn&#039;t know that Execute on a connection object<BR> returned a recordset, if so then i can&#039;t help you.<BR> 2. I assume your sql string is abbreviated as well...<BR> 3. Skip 2.. But I prefer to use If (Len(RS("photo")) = 0) as opposed to If (RS("photo") = "") ... I think it&#039;s a little faster, but a very tiny bit at that. Hope #1 helps<BR><BR>Jason<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts