ACCESS的参数化查询
2008-11-22 00:00:00 来源:WEB开发网 Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value)
参数同上
以下是实例,查询news表中所有tsing发表的新闻
------------------------------------------------------
et conn = Server.CreateObject("Adodb.Connection")
conn.ConnectionString = connString
conn.open()
set mycmd = Server.CreateObject("ADODB.Command")
mycmd.ActiveConnection=conn
mycmd.CommandText=sql
mycmd.Prepared = true
set mypar = mycmd.CreateParameter("temp",129,1,50,"tsing")
mycmd.Parameters.Append mypar
set myrs = mycmd.Execute
与上面基本相同不同的地方法是asp在对参数的表达上面不同
129为adChar,1就是指示输入参数(是其实是默认值)
大家请参阅MICROSOFT的ADOVB.Inc:
’---- ParameterDirectionEnum Values ----
Const adParamUnknown = 0
Const adParamInput = 1
Const adParamOutput = 2
Const adParamInputOutput = 3
Const adParamReturnValue = 4
’---- DataTypeEnum Values ----
Const adEmpty = 0
Const adTinyInt = 16
Const adSmallInt = 2
Const adInteger = 3
Const adBigInt = 20
Const adUnsignedTinyInt = 17
Const adUnsignedSmallInt = 18
Const adUnsignedInt = 19
Const adUnsignedBigInt = 21
Const adSingle = 4
Const adDouble = 5
Const adCurrency = 6
Const adDecimal = 14
Const adNumeric = 131
Const adBoolean = 11
Const adError = 10
Const adUserDefined = 132
Const adVariant = 12
Const adIDispatch = 9
Const adIUnknown = 13
Const adGUID = 72
Const adDate = 7
Const adDBDate = 133
Const adDBTime = 134
Const adDBTimeStamp = 135
Const adBSTR = 8
Const adChar = 129
Const adVarChar = 200
Const adLongVarChar = 201
Const adWChar = 130
Const adVarWChar = 202
Const adLongVarWChar = 203
Const adBinary = 128
Const adVarBinary = 204
Const adLongVarBinary = 205
附我写的C#类,和VBSCRIPT函数,希望对大家有帮助
- ››查询Oracle正在执行和执行过的SQL语句
- ››Access数据库安全策略之ASP式
- ››Accessibility.updateProperties ,Accessibility...
- ››查询Oracle对象lock信息
- ››查询数据库中有没有相同的值
- ››查询 XML 数据库外的 XML 文档
- ››Access denied for user...
- ››Access denied for user: root@dbhost (Using pas...
- ››access 的页怎么用
- ››Access 2000中的查询分析器
- ››access编程打开其他数据库中的窗体
- ››Access报表打印如何自动分页
更多精彩
赞助商链接