Getrows musings (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


yogaboy -> Getrows musings (1/14/2005 9:29:07)

I have been wondering....

Since Getrows uses an array, what if I have null values in fields in the first record that is returned? Does this mean that the array will have a smaller Ubound as it would if it was a normal array???

I say this because I'm having trouble with this exact situation and wondered if this could be the cause. I'm ok to try and sort it out on my own, I just couldn't find the answer to this little puzzler anywhere!




rdouglass -> RE: Getrows musings (1/14/2005 11:44:24)

If it returned a record (whether the fields were null or not), your ubound should not be bothered. An array is basically a table in memory and cells can have any value any other variable can have; null, int, text, boolean, etc.

Remember arrays are zero-based so the first row would be row 0 not row 1.




yogaboy -> RE: Getrows musings (1/14/2005 11:51:56)

Thanks for clearing that up. I've added a column to be returned in a select statement and changed the WHERE clause to return a record that I know has a value in that column, but the Ubound has stayed the same. I'll keep looking, as I'm not sure what's going on - but if I don't crack it I will be back![:D]




rdouglass -> RE: Getrows musings (1/14/2005 13:10:25)

I have a page I use to confirm all the data I am returning to my array. Pop this code on an ASP page by itself; change the connection and query, and browse to it. It basically dumps the array grabbed by getrows into a table.

It may shed some light on what is actually being returned.

<html>

<head>
<title>GetRows Test</title>
</head>

<body>
<%
Dim arrDBData, conntemp, I, J, rstemp
Dim iRecFirst, iRecLast, iFieldFirst, iFieldLast

Set conntemp = Server.CreateObject("ADODB.Connection")

' Change this line for your database depending on connection:
conntemp.Open "DSN=xxxx;uid=xxx;pwd=xxx;database=xxxx"

' Change this line for your table or query:
Set rstemp = conntemp.Execute("SELECT * FROM tblUsers")

arrDBData = rstemp.GetRows()

rstemp.Close
Set rstemp = Nothing
conntemp.Close
Set conntemp = Nothing

iRecFirst   = LBound(arrDBData, 2)
iRecLast    = UBound(arrDBData, 2)
iFieldFirst = LBound(arrDBData, 1)
iFieldLast  = UBound(arrDBData, 1)

%>
<table border="1">
<%For I = iRecFirst To iRecLast
	Response.Write "<tr>" & vbCrLf
	For J = iFieldFirst To iFieldLast
		Response.Write vbTab & "<td>" & arrDBData(J, I) & "</td>" & vbCrLf
	Next
	
	Response.Write "</tr>" & vbCrLf
Next%>
</table>
</body>

</html>




yogaboy -> RE: Getrows musings (1/17/2005 6:08:28)

Thanks for that - got it sorted and realized I still wasn't pulling the right stuff out of the database anyway! The joys of computing[:)]




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625