1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Sub test()
Debug.Print TrouveTypeSql("")
Debug.Print TrouveTypeSql(strFileName)
Debug.Print TrouveTypeSql("toto")
Debug.Print TrouveTypeSql(Date)
Debug.Print TrouveTypeSql(Now)
Debug.Print TrouveTypeSql(10.5)
SQL= "INSERT INTO Files (Path, File, DateLastModified) VALUES (" & TrouveTypeSql(strFilePath) & "," & TrouveTypeSql(strFileName) & "," & TrouveTypeSql(dtDateLastModified) & ")"
Debug.Print SQL
cnn.Execute SQL
End Sub
Function TrouveTypeSql(V)
TrouveTypeSql = Trim("" & V)
If Trim("" & TrouveTypeSql) = "" Then TrouveTypeSql = "Null": Exit Function
If IsDate(TrouveTypeSql) = True And InStr(TrouveTypeSql, "/") <> 0 And InStr(TrouveTypeSql, ":") <> 0 Then TrouveTypeSql = "#" & Format(TrouveTypeSql, "yyyy-mm-dd hh:mm") & "#": Exit Function
If IsDate(TrouveTypeSql) = True And InStr(TrouveTypeSql, "/") <> 0 Then TrouveTypeSql = "#" & Format(TrouveTypeSql, "yyyy-mm-dd") & "#": Exit Function
If IsNumeric(Replace(TrouveTypeSql, ".", ",")) = True Then TrouveTypeSql = Replace(TrouveTypeSql, ",", "."): Exit Function
TrouveTypeSql = "'" & Replace(TrouveTypeSql, "'", "''") & "'"
End Function |
Partager