WEB开发网
开发学院数据库Access ACCESS的参数化查询 阅读

ACCESS的参数化查询

 2008-11-22 00:00:00 来源:WEB开发网   
核心提示: Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value)参数同上以下是实例,查询news表中所有tsing发表的新闻--et conn = Server.CreateObject("Adod

  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函数,希望对大家有帮助

Tags:ACCESS 参数 查询

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接