我想传递
Sub conect()
Dim cn As Object
Dim rs As New ADODB.Recordset
Dim sCon As String
Dim Count As String
Dim nMitt As String
Dim eMitt As String
Dim oGget As String
Dim mEss As String
Dim dEst As String
Dim tIme As String
Dim sSQL As String
Dim oNameSpace As Outlook.NameSpace
Dim oItem As Outlook.MailItem
Dim oFolder As Outlook.MAPIFolder
Set cn = CreateObject("ADODB.Connection")
sCon = "Driver={MySQL ODBC 5.1 Driver};Server=192.168.27.249;Database=PROTOCOLLI;" _
& "User=Riscoat;Password=Riscoat;Option=3;"
cn.Open sCon
Set oNameSpace = Application.GetNamespace("MAPI")
Set oFolder = GetNamespace("MAPI").Folders("riscoat").Folders("1.PROTOCOLLI")
rs.Open "SELECT PROT FROM RISCOAT ORDER BY PROT DESC LIMIT 1", sCon
Count = rs.Fields("PROT")
For Each oItem In oFolder.Items
Count = Count + 1
nMitt = ReplaceCharsForFileName(oItem.SenderName, " ")
eMitt = ReplaceCharsForFileName(oItem.SenderEmailAddress, " ")
oGget = ReplaceCharsForFileName(oItem.Subject, " ")
mEss = ReplaceCharsForFileName(oItem.Body, " ")
dEst = ReplaceCharsForFileName(oItem.To, " ")
tIme = oItem.ReceivedTime
cn.Execute = "IF NOT EXISTS (SELECT * FROM RISCOAT WHERE MESSAGGIO = '" & mEss & "' and DATA = '" & tIme & "') & INSERT INTO RISCOAT (PROT, NOME_MITT, MITTENTE, OGGETTO, MESSAGGIO, DESTINATARIO, DATA) VALUES ('" & Count & "','" & nMitt & "', '" & eMitt & "', '" & oGget & "', '" & mEss & "', '" & dEst & "', '" & tIme & "')"
-------only try ----------
' cn.Execute = "INSERT INTO RISCOAT (PROT, NOME_MITT, MITTENTE, OGGETTO, MESSAGGIO, DESTINATARIO, DATA) VALUES ('" & Count & "','" & nMitt & "', '" & eMitt & "', '" & oGget & "', '" & mEss & "', '" & dEst & "', '" & tIme & "')ON DUPLICATE KEY UPDATE PROT = '" & Count & "', NOME_MITT = '" & nMitt & "', MITTENTE = '" & eMitt & "', OGGETTO = '" & oGget & "', MESSAGGIO = '" & mEss & "', DESTINATARIO = '" & dEst & "', DATA = '" & tIme & "'"
' cn.Execute "IF EXISTS (SELECT * FROM RISCOAT WHERE MESSAGGIO = '" & mEss & "' and DATA = '" & tIme & "') " & _
"THEN UPDATE RISCOAT SET WHERE MESSAGGIO = '" & mEss & "' and DATA = '" & tIme & "' " & _
"ELSE INSERT INTO RISCOAT (PROT, NOME_MITT, MITTENTE, OGGETTO, MESSAGGIO, DESTINATARIO, DATA) " & _
"VALUES ('" & Count & "','" & nMitt & "', '" & eMitt & "', '" & oGget & "', '" & mEss & "', '" & dEst & "', '" & tIme & "')"
Next
End Sub
Private Function ReplaceCharsForFileName(ByVal sName As String, sChr As String) As String
sName = Replace(sName, "'", sChr)
sName = Replace(sName, "*", sChr)
sName = Replace(sName, "/", sChr)
sName = Replace(sName, "\", sChr)
' sName = Replace(sName, ":", sChr)
' sName = Replace(sName, "?", sChr)
sName = Replace(sName, Chr(34), sChr)
sName = Replace(sName, "<", sChr)
sName = Replace(sName, ">", sChr)
sName = Replace(sName, "|", sChr)
ReplaceCharsForFileName = sName
End Function
但我得到了一个例外
ObjectId obj_id = new ObjectId("8cb2010d27e13509d364436256e972c0");
query.addCriteria(Criteria.where("zones.$id").is(obj_id));
但是当我从我的mongo shell传递相同的Hexa值时,我得到了我的输出。我无法理解出了什么问题。任何人都可以帮助我吗?
我还想知道有没有简单的方法可以使用spring在mongo文档中使用DBRef查询对象