0

我正在尝试使用 asp classic 将参数日期传递给函数:我的数据库中有日期时间格式:2012-02-22 00:00:00,但我的参数将只包含“2012-02-22”所以它不起作用我收到一个空的 rs。

    <!--#include file="JSON.asp" -->
<!--#include file="JSON_UTIL_0.1.1.asp" -->

<%
function concours(datedp)
Dim sConnection, objConn , objRS 
Const adCmdText = &H0001
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
    BD_serveur = "localhost"
    BD_utilisateur = "root"
    BD_password = ""
    BD_nom = "emploipublic"
    'datedp= "2012-02-22"

    sConnection ="DRIVER={MySQL ODBC 5.1 Driver}; SERVER=" & BD_serveur & ";UID=" & BD_utilisateur & ";pwd=" & BD_password & ";database=" & BD_nom & ";option=3;"

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open(sConnection)

Set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandType = adCmdText 
Set cmd.ActiveConnection = conn

cmd.CommandText = "SELECT * FROM concours WHERE DATE(dateDepot)='"& datedp & "'"

Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open cmd, ,adOpenForwardOnly,adLockReadOnly 

Dim jsonObject

Set jsonObject = New JSON   'JSON class is in the include file json.asp'
jsonResult =  jsonObject.toJSON(Empty, rs, False) 


Response.ContentType = "application/json" 

Response.Write jsonResult

end function 


concours("2012-02-22")
4

1 回答 1

0
SQL = "SELECT * FROM concours WHERE dateDepot='"& datedp & "'"
于 2013-04-03T11:50:21.397 回答