发送搜索指针以开始进行MS访问 [英] Send search Pointer to start in MS access

查看:59
本文介绍了发送搜索指针以开始进行MS访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下,然后在此处复制代码,这是我写的问题,当我查询一段时间时,它在代码提及中显示pincode作为查询,并且一段时间未找到,而今天它显示空白,没有结果,甚至没有错误查询,我认为问题是当我查询数据时,指针位于最后查询的记录位置,但又没有刷新内存并转到数据库或程序中,任何人都可以帮助我摆脱它关闭

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

代码在asp中 查询MS Access MDB 2003

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>

推荐答案

要将记录集指针移至第一条记录:

To move the recordset pointer to the first record:

rs.MoveFirst

要检查记录集中是否有记录,您需要检查EOF和BOF是否为真:

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.

这篇关于发送搜索指针以开始进行MS访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆