bostjank
01-05-2003, 07:34 PM
Hi!
I have an interesting problem which I sometimes come by when I'm retrieving values from a database. I try, for example, to show the value in the filed named "Name"
set rs = conn.Execute(sSQL)
If rs("Name") <> "" Then
Response.Write "Name: " & rs("Name")
Else
Response.Write "Name: no data"
End If
It sometimes happens that the value in the "Name" field is <> then "", but the value is not shown, as if the value of rs("Name") would be set to "" once I checked its value. I can avoid this problem so that I first asign the value to a variable and then operate with that:
set rs = conn.Execute(sSQL)
sName = rs("Name")
If sName <> "" Then
Response.Write "Name: " & sName
Else
Response.Write "Name: no data"
End If
As I said, I can avoid the problem, but I wonder what's the problem, since this problem doesn't always occur (when it does, it of course applies to whole recordset, not just random records) and the soluton is more time consuming than the "original".
Does anybody know what can I do? This is how I access the database (Access)
<%
sConn = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database.mdb")
Set conn = Server.CreateObject("adodb.connection")
conn.open sConn,"",""
sSQL = "..."
set rs = conn.Execute(sSQL)
Do While Not rs.EOF
...
Loop
%>
Thanks,
Bostjan :thumbsup:
I have an interesting problem which I sometimes come by when I'm retrieving values from a database. I try, for example, to show the value in the filed named "Name"
set rs = conn.Execute(sSQL)
If rs("Name") <> "" Then
Response.Write "Name: " & rs("Name")
Else
Response.Write "Name: no data"
End If
It sometimes happens that the value in the "Name" field is <> then "", but the value is not shown, as if the value of rs("Name") would be set to "" once I checked its value. I can avoid this problem so that I first asign the value to a variable and then operate with that:
set rs = conn.Execute(sSQL)
sName = rs("Name")
If sName <> "" Then
Response.Write "Name: " & sName
Else
Response.Write "Name: no data"
End If
As I said, I can avoid the problem, but I wonder what's the problem, since this problem doesn't always occur (when it does, it of course applies to whole recordset, not just random records) and the soluton is more time consuming than the "original".
Does anybody know what can I do? This is how I access the database (Access)
<%
sConn = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database.mdb")
Set conn = Server.CreateObject("adodb.connection")
conn.open sConn,"",""
sSQL = "..."
set rs = conn.Execute(sSQL)
Do While Not rs.EOF
...
Loop
%>
Thanks,
Bostjan :thumbsup: