An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only.Download presentation by click this link.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.
例,返回记录集,并显示记录<%Set db=Server.CreateObject("ADODB.Connection") db.Open"zbsdbbszb"set rs=db.execute("select * from article where name='张三'") do while not rs.eofresponse.write rs("title")&"<br>"rs.movenextloop%>
第二种,db.Execute SQL字符串这种方法不返回一个Recordset对象。如果对数据库执行的是添加、删除和更新操作,由于没有必要返回记录集,所以可以采用这种方法。 • 例:执行数据库的删除操作<%Set db=Server.CreateObject("ADODB.Connection") db.Open"zbsdbbszb" strsql="delete from article where name='张三'"db.execute strsql • %>
建立Recordset对象的方法 • 利用Connection对象的Execute方法建立 <% Dim conn Set conn=Server.CreateObject("ADODB.Connection") conn.Open "address" Dim rs Set rs=conn.Execute("Select * From tbAddress") %> • 这种方法是最常用的方法。但功能有限。
利用Connection对象但明确建立Recordset对象的方式 • <% Dim conn Set conn=Server.CreateObject("ADODB.Connection") conn.Open "address" Dim rs Set rs=Server.CreateObject("ADODB.Recordset") rs.Open "Select * From tbAddress",conn,1,2,1 %> • 说明:这是将方法一修改为明确建立Recordset对象。通过参数配置,增强功能,还可用于删除、添加、修改等操作。
Recordset对象的重要属性 • Source、ActiveConnection、CursorType、LockType属性 • 这一组属性主要用于设定记录集的特性。 • <% Dim rs Set rs=Server.CreateObject("ADODB.Recordset") rs.Source="Select * From tbAddress“ rs.ActiveConnection=conn rs.CursorType=1 '设置为键盘指针,可前后移 rs.LockType=2 '设置可被一个客户修改 rs.Open '打开记录集 %>