Help with a function

Results 1 to 3 of 3

Thread: Help with a function

  1. #1
    Join Date
    Dec 1969
    Posts
    730

    Default Help with a function

    I want to pass a recordset into a function for evaluation. It works fine for the first one, but it doesn&#039t loop or is just not getting the rest. Here is the code:<BR><BR>&#039all the database stuff<BR>i = 1<BR>do while not rs.eof<BR>checkRecordSet(rs("field" & i))<BR>i=i+1<BR>rs.movenext<BR>loop<BR><BR>functio n CheckRecordSet(therecord)<BR> if therecord &#060;> " " then<BR> response.write "here is the recordset"<BR> end if<BR>end function<BR><BR>what am i doing wrong here?<BR><BR>thanks in advance!<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Help with a function

    Hmmm... I think you are a bit confused. A recordset is a collection of values from a database. It&#039s best to think of a recordset as a matrix:<BR><BR>Name : Age<BR>------------<BR>Bob : 20<BR>Sue : 31<BR>Frank : 34<BR><BR>The recordset object would encompass all of that information, initially pointing to the first row (Bob:20). To move to the next row, you&#039d issue: rs.MoveNext.<BR><BR>To obtain the name for a given row, you&#039d say, rs("Name"), or rs(0). To get the price, you&#039d issue, rs("Price") or rs(1).<BR><BR>So, what are you wanting to pass to your function? The entire row? A single cell in this matrix, is what I assume; however, you seem to be passing in a different column for each row, or at least like you&#039re trying to do that. What, exactly, do you want your function to do?

  3. #3
    Join Date
    Dec 1969
    Posts
    730

    Default RE: Help with a function

    Sorry to confuse you. I have a database that can hold up to 7 urls. The links are entered by users at the website. I want to be able to query the database and place the information into table rows. The catch is that i only want the rows equal to the number of urls entered by the user. Example: joe enters only three links. I want to create only 3 rows. Sally enters all seven links. I want to create exactly 7 rows. I was going to use the function to check each recordset to determine if they have a value. It is possible that someone entered number 1, 2 and skiped to 7. I want the function to tell me that there is a value in 1,2 and 7 and the rest is null. Do you follow or am i just completely insane? I have a crude/non elegant version working now. I&#039m just looking for another way of doing things.<BR><BR>Here is what is working for me now:<BR><BR>&#060;% If RSlinks.EOF then &#037;&#062; <BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;font face="Arial" size="2">You have no links. Enter some &#060;a href="process.asp?action=addlinks">&#060;font face="Arial" size="2" color="Blue">here.&#060;/font>&#060;/a>&#060;/font>&#060;/td><BR> &#060;/tr><BR> &#060;% Else &#037;&#062;<BR> &#060;% do while not RSLinks.eof &#037;&#062;<BR> &#060;% &#039the if statements are used to ensure that we don&#039t create any more rows than we need to &#037;&#062;<BR> &#060;% if RSLinks("link1") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link1") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name1") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr><BR> &#060;% End If &#037;&#062;<BR> &#060;% if RSLinks("link2") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link2") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name2") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr><BR> &#060;% End If &#037;&#062;<BR> &#060;% if RSLinks("link3") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link3") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name3") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr><BR> &#060;% End If &#037;&#062;<BR> &#060;% if RSLinks("link4") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link4") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name4") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr><BR> &#060;% End If &#037;&#062;<BR> &#060;% if RSLinks("link5") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link5") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name5") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr><BR> &#060;% End If &#037;&#062;<BR> &#060;% if RSLinks("link6") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link6") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name6") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr><BR> &#060;% End If &#037;&#062;<BR> &#060;% if RSLinks("link7") &#060;> " " then &#037;&#062;<BR> &#060;tr bgcolor=white ><BR> &#060;td colspan="3">&#060;img src="images/link.GIF" width=11 height=14 alt="" border="0">&#060;a href="&#060;%= RSLinks("link7") &#037;&#062;">&#060;font face="Arial" size="2" color="Blue">&#060;%= RSLinks("name7") &#037;&#062;&#060;/font>&#060;/a>&#060;/td><BR> &#060;/tr> <BR> &#060;% End If &#037;&#062;<BR> &#060;% RSLinks.movenext &#037;&#062;<BR> &#060;% loop &#037;&#062;<BR> &#060;% End If &#037;&#062;<BR><BR>thanks for your help!

Posting Permissions

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