如何使传统的ASP参数化的SQL查询? [英] How to make a parametrized SQL Query on Classic ASP?

查看:580
本文介绍了如何使传统的ASP参数化的SQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉我在VBScript中执行使用经典的ASP参数化SQL查询的最简单的方法?

Can someone show me the simplest way of perform a parametrized SQL query using Classic ASP in VBscript?

一个编译例子是最好的。

A compilable example would be best.

推荐答案

使用的adodb.command对象。

Use the adodb.command object.

with createobject("adodb.command")
    .activeConnection = application("connectionstring")
    .commandText = "select * from sometable where id=?"
    set rs = .execute( ,array(123))
end with

我也建议使用,而不是直接使用ADODB的自定义数据库访问对象。这使您可以建立一个更好的API,提高了可测试性和增加挂钩debuging /日志/分析。其次,你可以使用class_terminiate事件错误使用隐式回退的添加请求范围内的事务。欧勒DB访问对象提供了以下查询API

I would also advise to use a custom db access object instead of using adodb directly. This allows you to build a nicer api, improves testability and add hooks for debuging/logging/profiling. Secondly you can add request scoped transactions with implicit rollback's on errors using the class_terminiate event. Oure db access object offers the following query api

call db.execute("update some_table set column=? where id=?", array(value, id))
set rs = db.fetch_rs("select * from some_table where id=?", array(id))
count = db.fetch_scalar("select count(*) from some_table where column > ?", array(value))

这篇关于如何使传统的ASP参数化的SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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