Virgil Bierschwale wrote:
> Ok, I have empty fields in sql server and I need to replace them with &nbsp
> when they're null.
> 

ISNULL ( check_expression , replacement_value )

Use it this way : Select isnull(possiblyNullField, '&nbsp') as
'possiblyNullField' ........
It will return the fields contents if any or the replacement_value if
the field is null.


> Apparently vbscript is a lot different then what I did in the past and I
> havent had much luck googling it.
> 
> How do ya'll trap for null in the code below ?
> 
> In the past I would have done it at before each response.write line, but the
> few samples I have found don't seem to work.
> 
> You can try out the code at http://www.virgilslist.com/branch.asp
> 
> Thanks
> 
> Virgil Bierschwale
> http://www.virgilslist.com
> http://www.tccutlery.com
> http://www.bierschwale.com
> http://www.bierschwalesolutions.com
> 
> 
> tablename = "roster"
> 
> 
> fieldname1 = "svcbranch"
> fieldname2 = "svcunit"
> fieldname3 = "svcrate"
> fieldname4 = "svcrank"
> fieldname5 = "svclastname"
> fieldname6 = "svcfirstname"
> fieldname7 = "svccity"
> fieldname8 = "svcstate"
> fieldname9 = "svczip"
> fieldname10 = "svconboard"
> fieldname11 = "svcdeparted"
> fieldname12 = "svclatitude"
> fieldname13 = "svclongitude"
> 
> connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" &
> db_name & ";UID=" & db_username & ";PWD=" & db_userpassword
> 
> Set oConn = Server.CreateObject("ADODB.Connection")
> oConn.Open connectstr
> 
> qry = "SELECT " & fieldname3 & ", " & fieldname6 & ", " & fieldname5 & ", "
> & fieldname7 & ", " & fieldname8 & ", " & fieldname9 & ", " & fieldname10 &
> ", " & fieldname11 & " FROM " & tablename & " where " & fieldname2 & " = '"
> & svcBranch & "'"
> Set oRS = oConn.Execute(qry)
> 
> Response.Write("<table border='1' id='table7'>" & vbCrLf)
> Response.Write("<tr>" & vbCrLf)
> 
> 
> 
> Do until oRs.EOF
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname3) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname6) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname5) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname7) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname8) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname9) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname10) & "</td>" & vbCrLf)
>    Response.Write("<td>" & vbCrLf)
>    Response.Write(oRs.Fields(fieldname11) & "</td>" & vbCrLf)
>    Response.Write("</tr>" & vbCrLf)   
>    oRS.MoveNext
> Loop
> Response.Write("</table>" & vbCrLf)
> oRs.Close
> 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to