Boa tarde, então eu tenho um formulário no Access que serve para sincronizar os dados do Access para o Mysql, mas parece que recentemente ele fez o caminho inverso, tinha dados que não tinha no Mysql mas tinha no Access, e parece que ele apagou. Eu queria remover esse espelhamento do Mysql para o Access. Alguém podia me informar onde eu posso mudar isso? Obrigado.
Private Sub CmdRepair_Click()
Dim response
Dim body As String
Dim obj As New Dictionary
Dim rs As Recordset
Dim i As Integer
Dim keyValue As New Dictionary
Dim id As Variant
Dim tables() As String
Dim table As Variant
Dim localFields As Dictionary
Dim remoteTable As String
Dim syncItemCounter As Integer
Dim field As Variant
Dim fieldsString As String
Dim Data As New Dictionary
Dim responseList As Collection
TxtResult = Empty
InactivateComponents
i = SynchronizeHelper.SyncronizePendingChanges
TxtResult = TxtResult & "Itens pendentes: "
If i > -1 Then 'Houveram itens na tabela de sincronizações pendentes
If i = 0 Then 'A diferença entre enviado e pendência = 0
TxtResult = TxtResult & "todos sincronizados" & vbCrLf
Else
TxtResult = TxtResult & i & " falharam" & vbCrLf
End If
Else
TxtResult = TxtResult & " nenhum item pendente" & vbCrLf
End If
TxtResult = TxtResult & vbCrLf
tables = GetSelectedTables
If Len(tables(0)) = 0 Then
TxtResult = TxtResult & "Nenhuma tabela selecionada para reparação"
Exit Sub
End If
For Each table In tables
TxtResult = TxtResult & "Tabela " & table & ": "
Set localFields = Mappings.GetFieldsMappings(table)
remoteTable = Mappings.GetTableMappings(table)
fieldsString = Empty
i = 1
For Each field In localFields
fieldsString = fieldsString & localFields(field) & IIf(i < localFields.count, ", ", "")
i = i + 1
Next
Set rs = CurrentDb.OpenRecordset("SELECT " & fieldsString & " FROM [" & table & "] WHERE ativo = true")
If rs.RecordCount > 0 Then
syncItemCounter = 0
Data.RemoveAll
While Not rs.EOF
Dim tempDictionary As Object
Set tempDictionary = CreateObject("Scripting.Dictionary")
For Each field In localFields
If field <> "id_bd_access" Then
tempDictionary.Add field, rs.fields(localFields(field)).value
End If
Next
tempDictionary.Add "ativo", 1
Data.Add rs.fields(localFields("id_bd_access")).value, tempDictionary
rs.MoveNext
Wend
rs.Close
obj("table") = remoteTable
obj("secret") = Secret.Code
obj("ids") = Data.Keys
body = JsonConverter.ConvertToJson(obj)
Set response = HttpHelper.HttpRequest("POST", ReportHelper.SERVER_URL & "get_missing_values.php", True, body)
If Not response Is Nothing Then
If response.count > 0 Then
For Each id In response
Dim syncObj As Dictionary
Set syncObj = SynchronizeHelper.CreateSyncObject(remoteTable, id, Data(id))
If SynchronizeHelper.Synchronize(syncObj) Then
syncItemCounter = syncItemCounter + 1
End If
Next
TxtResult = TxtResult & syncItemCounter & "/" & response.count & " sincronizados." & vbCrLf
Else
TxtResult = TxtResult & " já atualizada. " & vbCrLf
End If
Else
TxtResult = TxtResult & " erro de conexão. " & vbCrLf
TxtResult = TxtResult & " Processo abortado!" & vbCrLf
ReactivateComponents
Exit Sub
End If
Else
TxtResult = TxtResult & " vazia." & vbCrLf
End If
Next
ReactivateComponents
TxtResult = TxtResult & vbCrLf & "Concluído!"
End Sub
Private Sub CmdRepair_Click()
Dim response
Dim body As String
Dim obj As New Dictionary
Dim rs As Recordset
Dim i As Integer
Dim keyValue As New Dictionary
Dim id As Variant
Dim tables() As String
Dim table As Variant
Dim localFields As Dictionary
Dim remoteTable As String
Dim syncItemCounter As Integer
Dim field As Variant
Dim fieldsString As String
Dim Data As New Dictionary
Dim responseList As Collection
TxtResult = Empty
InactivateComponents
i = SynchronizeHelper.SyncronizePendingChanges
TxtResult = TxtResult & "Itens pendentes: "
If i > -1 Then 'Houveram itens na tabela de sincronizações pendentes
If i = 0 Then 'A diferença entre enviado e pendência = 0
TxtResult = TxtResult & "todos sincronizados" & vbCrLf
Else
TxtResult = TxtResult & i & " falharam" & vbCrLf
End If
Else
TxtResult = TxtResult & " nenhum item pendente" & vbCrLf
End If
TxtResult = TxtResult & vbCrLf
tables = GetSelectedTables
If Len(tables(0)) = 0 Then
TxtResult = TxtResult & "Nenhuma tabela selecionada para reparação"
Exit Sub
End If
For Each table In tables
TxtResult = TxtResult & "Tabela " & table & ": "
Set localFields = Mappings.GetFieldsMappings(table)
remoteTable = Mappings.GetTableMappings(table)
fieldsString = Empty
i = 1
For Each field In localFields
fieldsString = fieldsString & localFields(field) & IIf(i < localFields.count, ", ", "")
i = i + 1
Next
Set rs = CurrentDb.OpenRecordset("SELECT " & fieldsString & " FROM [" & table & "] WHERE ativo = true")
If rs.RecordCount > 0 Then
syncItemCounter = 0
Data.RemoveAll
While Not rs.EOF
Dim tempDictionary As Object
Set tempDictionary = CreateObject("Scripting.Dictionary")
For Each field In localFields
If field <> "id_bd_access" Then
tempDictionary.Add field, rs.fields(localFields(field)).value
End If
Next
tempDictionary.Add "ativo", 1
Data.Add rs.fields(localFields("id_bd_access")).value, tempDictionary
rs.MoveNext
Wend
rs.Close
obj("table") = remoteTable
obj("secret") = Secret.Code
obj("ids") = Data.Keys
body = JsonConverter.ConvertToJson(obj)
Set response = HttpHelper.HttpRequest("POST", ReportHelper.SERVER_URL & "get_missing_values.php", True, body)
If Not response Is Nothing Then
If response.count > 0 Then
For Each id In response
Dim syncObj As Dictionary
Set syncObj = SynchronizeHelper.CreateSyncObject(remoteTable, id, Data(id))
If SynchronizeHelper.Synchronize(syncObj) Then
syncItemCounter = syncItemCounter + 1
End If
Next
TxtResult = TxtResult & syncItemCounter & "/" & response.count & " sincronizados." & vbCrLf
Else
TxtResult = TxtResult & " já atualizada. " & vbCrLf
End If
Else
TxtResult = TxtResult & " erro de conexão. " & vbCrLf
TxtResult = TxtResult & " Processo abortado!" & vbCrLf
ReactivateComponents
Exit Sub
End If
Else
TxtResult = TxtResult & " vazia." & vbCrLf
End If
Next
ReactivateComponents
TxtResult = TxtResult & vbCrLf & "Concluído!"
End Sub