473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Recordset Problem / asp, vbscript, Ms Access

21
I want to create a Recordset and after that start a loop and within that loop i am creating more other recordset.

But Recordset within the loop is not working properly i.e. they are not getting expected value.
.

For example

Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Dim Recordset1a 
  4.  
  5. dateRa = date()
  6.  
  7. Set Recordset1a = Server.CreateObject("ADODB.Recordset")
  8. Recordset1a.ActiveConnection = srtring_conneting
  9.  
  10. Recordset1a.Source = "SELECT *  FROM book  WHERE name "
  11.  
  12. Recordset1a.CursorType = 0
  13. Recordset1a.CursorLocation = 2
  14. Recordset1a.LockType = 1
  15. Recordset1a.Open()
  16.  
  17. %>
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3.        While ( NOT Recordset1a.EOF ) 
  4. %>
  5.  
Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Dim RecordsetSubj, daySubj,subj
  4.  
  5. daySubj = date()
  6.  
  7. RecordsetSubj = ""
  8.  
  9. subj = ""
  10.  
  11.  
  12. subj = Recordset1a.Fields.Item("subject1").Value
  13.  
  14. Set RecordsetSubj = Server.CreateObject("ADODB.Recordset")
  15. RecordsetSubj.ActiveConnection = srtring_conneting
  16.  
  17. RecordsetSubj.Source = "SELECT * FROM table WHERE ( (( type = 200 )  AND (subject LIKE '%" + Replace(subj, 
  18.  
  19. "'", "''") + "%') AND (put_date LIKE '%" + Replace(daySubj, "'", "''") + "%')) ORDER BY put_date desc"
  20.  
  21.  
  22. RecordsetSubj.CursorType = 0
  23. RecordsetSubj.CursorLocation = 2
  24. RecordsetSubj.LockType = 1
  25. RecordsetSubj.Open()
  26.  
  27. %>
  28.  
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim RecordsetSubj1, daySubj1,subj1
  3.  
  4. RecordsetSubj1 = ""
  5. subj1 = ""
  6.  
  7. daySubj1 = date()
  8.  
  9.  
  10. subj1 = Recordset1a.Fields.Item("subject2").Value
  11.  
  12. Set RecordsetSubj1 = Server.CreateObject("ADODB.Recordset")
  13. RecordsetSubj1.ActiveConnection = srtring_conneting
  14.  
  15. RecordsetSubj1.Source = "SELECT * FROM table WHERE ( (( type = 100 ) AND (put_date LIKE '%" + Replace
  16.  
  17. (daySubj1, "'", "''") + "%'))  ) ORDER BY put_date desc"
  18.  
  19. RecordsetSubj1.CursorType = 0
  20. RecordsetSubj1.CursorLocation = 2
  21. RecordsetSubj1.LockType = 1
  22. RecordsetSubj1.Open()
  23.  
  24. 'Recordset1_numRows = 0
  25. %>
  26.  
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.   Repeat1__numRowsa = Repeat1__numRowsa-1
  3.   Recordset1a.MoveNext()
  4. Wend
  5. %>
  6.  

Here RecordsetSubj, RecordsetSubj1 is not getting the expected value.

Is it wrong to create recordset with a loop as well as taking the dynamic value i.e. from database.

Please help me
Sep 27 '07 #1
3 2604
ilearneditonline
130 Expert 100+
I would split out the inner queries and write a couple of functions. Then I would call the functions from the loop.
Sep 27 '07 #2
Dilruba
21
Thanks for ur guideline and suggestion.

But my question was "Is it wrong to create recordset with a loop as well as taking the dynamic value i.e. from database?"
Sep 28 '07 #3
jhardman
3,406 Expert 2GB
Thanks for ur guideline and suggestion.

But my question was "Is it wrong to create recordset with a loop as well as taking the dynamic value i.e. from database?"
Besides personal preferences, yes it is wrong to create a recordset inside the loop like you did. At least the "set recordset..." line should be outside of the loop, whether you re-fill the rs every time through the loop or not. After that, you could open and close the recordset with a new query every time you go through the loop and that would be valid.

Jared
Sep 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is...
18
by: Darryl Kerkeslager | last post by:
When I open an ADO Recordset, I close it. However, it seems that there may be some difference in this manner of opening a Recordset: Dim rL As ADODB.Recordset Set rL = New ADODB.Recordset ...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
2
by: Kosmos | last post by:
I am opening the following connections as such although I am only referring to the first connection for this question: Dim con1 As ADODB.Connection Dim con2 As ADODB.Connection Dim recSet1 As...
0
by: madankarmukta | last post by:
Hi All, I am interested in knowing Users Count who all are Currently accessing the File File1.txt. I wrote a Vb Script to get the user Count. I am running the script on XP professional...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.