DATETIME MYSQL & ASP CLASSIC



我试图通过一个参数日期使用asp经典函数:我有datetime格式: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")
SQL = "SELECT * FROM concours WHERE dateDepot='"& datedp & "'"

最新更新