473,395 Members | 2,192 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,395 software developers and data experts.

0 record returned from recordset

144 100+
hi,

i'm trying to select some record from a table in my msaccess.mdb (it's a 2007 ms access). here's the sql query
Expand|Select|Wrap|Line Numbers
  1. select * from msNews where title like '*a*'
when queried it in ms access, i got some records returned. but then i try to query the database using the same sql query, but the rs.RecordCount returns 0.

here's the asp code

Expand|Select|Wrap|Line Numbers
  1. rs.open "select * from msNews where judul like '*a*'", conn        
  2.  
  3. response.write(rs.Recordcount)  'this shows 0
  4.  

is something wrong?
thanks
Nov 5 '08 #1
7 9038
missinglinq
3,532 Expert 2GB
The one thing that is see that is wrong is that you've posted an ASP question in the Access forum! I'll transfer it to the ASP forum.

Linq ;0)>
Nov 5 '08 #2
DrBunchman
979 Expert 512MB
Hi thesti,

The RecordCount property will work only if you have used certain cursor types when opening your recordset.

If you try to loop through the returned recordset and display the records are they showing? If they are then we can look at changing the cursor that you are using to return the recordcount and if they aren't then the problem lies somewhere else.

If you are just trying to check whether any records have been returned then you can use the rs.EOF property, which stands for End Of File, like this:

Expand|Select|Wrap|Line Numbers
  1. If rs.EOF Then
  2.      Response.Write "No records returned!"
  3. Else
  4.      Response.Write "Some records were returned!"
  5. End If
Dr B
Nov 5 '08 #3
thesti
144 100+
hi,

thanks for the reply.

yes, i've used the rs.EOF or rs.BOF for checking whether there's any record returned or not. and i get "There's No news".

here's the declaration of the connection and rs object

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     'file for database connection
  3.     set conn = server.CreateObject("ADODB.Connection")
  4.     conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../db.mdb")
  5.  
  6.     set rs = Server.CreateObject("ADODB.Recordset")
  7.     rs.CursorLocation = 3
  8. %>
  9.  
and this is the query code

Expand|Select|Wrap|Line Numbers
  1. <%
  2.             'get news
  3.             if search <> "" then
  4.                 if modeSearch = "title" then
  5.                     'if search news based on title
  6.                     rs.open "select * from msNews where title like '*"&search&"*'", conn                        
  7.                 else 
  8.                     'search news based on meat
  9.                     rs.open "select * from msNews where meat like '*"&search&"*'", conn
  10.                 end if
  11.             else
  12.                 rs.open "select * from msNews", conn
  13.             end if
  14. %>
  15.  

here's the result displaying code

Expand|Select|Wrap|Line Numbers
  1. <%
  2.             'rs checking
  3.             if not (rs.BOF or rs.EOF) then            
  4.                 do while  Not ( rs.Eof or rs.AbsolutePage <> page )
  5. %>
  6.  
  7. <!-- render news in html -->
  8.  
  9. <%
  10.                     rs.moveNext
  11.                 Loop
  12.             else
  13.                 response.write("There's no News")
  14.             end if            
  15. %>                    
  16.  

it works find if the user doesn't search anything, all of the news are returned.
but i get "There's no News" when i search for some news that are exist in the database. what makes me wonder is that when i query the table directly from Ms Access 2007 using the same keyword that i've tried from the page, i get some records.

i don't know what possibly is wrong.

Thank you.
SC.
Nov 6 '08 #4
DrBunchman
979 Expert 512MB
Next thing to do then is to write your query to the screen using a Response.Write, copy and paste it into your query analyser and see if it returns any records then.

If it doesn't then there is a problem with how you are building the query in your ASP code.

Let me know how it goes.

Dr B
Nov 6 '08 #5
thesti
144 100+
hi,

i've done what you told me,

i type "test" in the text field of the search form, then
here's the query resulted from Response.Write

select * from msNews where title like '*test*'

after i run it in ms access query, it returns a record of which title is "test only".
while in my web app, i get "There's no News"


Thank you,
SC
Nov 6 '08 #6
thesti
144 100+
hi,

now i know what cause my problem,

in ms access the query

select * from msNews where title like '*test*'

works because it uses * asterisk as a wildcard. so i though that i should use the same sign in asp, but just now i try to change it to '%' and now i get the same result as it's run in ms access query.


Thank you for your help,
SC
Nov 6 '08 #7
DrBunchman
979 Expert 512MB
No problem, glad you got it fixed.

Dr B
Nov 6 '08 #8

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

Similar topics

8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
1
by: ms | last post by:
I am running an insert statement from a dbf file and there is one record causing the insert to fail. A msg. is returned stating it is due to an invalid datatype. There are 2 text fields, 2...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
8
by: MLH | last post by:
Before running the following line of code, I would like to first know if there is another record in the form's record source. If I run this line when the last record is current, an error is...
30
by: S. van Beek | last post by:
Dear reader A record set can be empty because the condition in the query delivers no records. Is there a VBA code to check the status of a record set, record set empty
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
6
by: ApexData | last post by:
When I use Dlookup. I am only able to return a single value and therefore cannot seem to assign a single records (3-field values) to (3-Variables). I noticed that I can get the 3-field values, but...
6
by: SethM | last post by:
I have a stored procedure that returns a record set. I want to functionalize this so I can have multiple presentations of the same record set. However, I can not get rs_event.open StoreProc to pass...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.