我正在尝试使用asp classic将参数日期传递给函数:我的格式为datetime:2012-02-22 00:00:00在我的数据库中,但我的参数将只包含'2012-02- 22' 所以它不起作用我收到一个空的。
<!--#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")
答案 0 :(得分:0)
SQL = "SELECT * FROM concours WHERE dateDepot='"& datedp & "'"