<% ' Database Connection Dim conexion, strDB strDB = Server.MapPath("../../surveys_iv.mdb") Set conexion = Server.CreateObject("ADODB.Connection") conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDB & ";" strtoday = Year(date) & "-" & Month(date) & "-" & Day(date) '--------------------------------------------------------- ' Functions Function get_customer_details (stremail) strquery = "SELECT * FROM customers WHERE email='" & stremail & "';" Set result = conexion.Execute(strquery) arrResult = fetch_table (result) if(Ubound(arrResult)<>-1) then Set get_customer_details = arrResult(0) ' There can be only one! else get_customer_details = false end if end Function Function get_questions (aintserviceid) strquery = "SELECT * FROM questions WHERE serviceid=" & aintserviceid & ";" Set result = conexion.Execute(strquery) arrResult = fetch_table (result) get_questions = arrResult end Function Function get_service_name ( aintserviceid ) strquery = "SELECT * FROM services WHERE id=" & aintserviceid & ";" Set result = conexion.Execute(strquery) arrResult = fetch_table (result) get_service_name = arrResult(0)("name") end Function Function check_order_number (aint) ' check if orderNumber is already in Database strquery = "SELECT * FROM surveys WHERE ordernum = '"&aint&"';" Set result = conexion.Execute(strquery) arrResult = fetch_table (result) if(Ubound(arrResult)=-1) then check_order_number = false ' order does not exist else check_order_number = true ' order exists end if end function '--------------------------------------------------------- ' RecordSet to Array of dictionaries function fetch_table (byref rst) dim columnas() fila = 0 redim columnas (0) while not rst.eof redim preserve columnas(ubound(columnas)+1) set columnas(fila) = CreateObject("Scripting.Dictionary") for each columna in rst.fields columnas(fila).add columna.name,columna.value next fila = fila + 1 rst.movenext wend redim preserve columnas(ubound(columnas)-1) fetch_table = columnas end Function function change_date_format ( astrdate ) arrDate = Split(astrdate, "/") change_date_format = arrDate(2) & "-" & arrDate(0) & "-" & arrDate(1) end function '------------------------------------------------------ ' Apostrophe Function fNStrSQL(astr) newstr = Replace (astr, "'", "´") ' newstr = Replace(newstr, ";", ";") ' newstr = Replace(newstr, """", """) fNStrSQL = newstr end Function Function fNStrPost(astr) newstr = Replace(astr, """", """) ' newstr = Replace(astr, """", "_") fNStrPost = newstr end Function %>