问题
My code is as follows before copying code here i have writing the problem, when i query some time it shows pincode as query in code mention and some time show not found and now today it is showing blank no result even no error on querying,i thought the problem is when i query the data the pointer is locate on the place of record where it is last queried but not again flush the memory and go to start of database or in program, any one help me how to get rid off
code is in asp querying mS access mdb 2003
<html>
<body>
<div id ="pin">
<%
city= Request.Form("username")
area = Request.Form("password")
Dim Conn,rs,strSQL
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open"Provider= Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/pinner/db/database1.mdb")
'Conn.Open"DRIVER=Microsoft Access Driver(*.mdb);DBQ=" & Server.MapPath("/pinner/db/Database1.mdb")
'strSQL = "SELECT pincodes.officename FROM pincodes where pincode = '" & city & "';"
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "Select pincode from pincodes WHERE Districtname = '" & city & "' AND officename = '" & area & "';"
'strSQL = "Select pincode from pincodes WHERE (Districtname like "&city& *" AND officename like "&area&*");"
rs.Open strSQL,Conn
If rs.EOF or rs.BOF Then
Response.Write ("<br>")
Response.Write ("[pincode] not found")
Response.Write ("<br>")
Else
Response.Write ("<br>")
Response.Write (rs("pincode"))
Response.Write ("<br>")
End If
rs.close
Conn.close
Set rs = Nothing
Set Conn = Nothing
%>
</div>
</body>
</html>
回答1:
To move the recordset pointer to the first record:
rs.MoveFirst
To check to see if there are any records in the recordset you need to check to see if both EOF and BOF are true:
If (rs.EOF AND rs.BOF) Then
Response.Write ("<br>")
Response.Write ("[pincode] not found")
Response.Write ("<br>")
Else
Response.Write ("<br>")
Response.Write (rs("pincode"))
Response.Write ("<br>")
End If
It sounds to me like you probably still have a problem in your query that is preventing you from finding the record you want.
来源:https://stackoverflow.com/questions/18804866/send-search-pointer-to-start-in-ms-access