Sto trasferendo un archivio MSAccess in un database SQLServer, senza utilizzare il tool SSMA for Access.
Tutto assolutamente OK ma, all'atto di trasferire il campo "PswDitta" appare il messaggio di errore allegato.
Il bello è che il campo precedente ("Psw") ("Psw" è il ventiduesimo e "PswDitta" il ventitreesimo) viene trasferito correttamente.
I 2 campi sono PERFETTAMENTI uguali. Ho controllato con estrema attenzione le caratteristiche dei 2 campi sia con Access (Strumenti database - Analizzatore database : AllowZeroLenght Vero) che con SSMS (sono entrambi nvarchar(8),Null - ma ho controllato anche la perfetta corrispondenza facendo click con il tasto destro su entrambi i campi). Sono uguali !
L'unica differenza (oltrechè il loro contenuto) è che Psw è il penultimo della tabella mentre Psw è l'ultimo.
Tutte le altre tabelle dell'archivio MDB sono trasferite correttamente, sempre utilizzando la medesima sub che qui, ahimè, fallisce.
Ho anche fatto una preventiva compattazione dell'MDB utilizzando Access.
Nessuno dei 2 campi è coinvolto in indici o altri diavolerie ma, ... niente !
Il mio scopo finale è quello di trasferire ANCHE il campo PswDitta.
Qualche suggerimento ?
Grazie per l'attenzione
codice:La sub che effettua i trasferimenti delle numerose tabelle è la seguente Sub LeggiTabella(NomeTabella) '--- leggo MSAccess e scrivo SQLServer Dim TuttiCampi As String Dim i As Integer Dim Criterio As String Dim strDate As String Dim rs As ADODB.Recordset Dim strDelim As String Dim S As String Dim TotCampi As Integer 'Dim Incremento As Integer ' nion usato Dim V As Long Dim rsTot As ADODB.Recordset Dim Tot As Long Set rsTot = New ADODB.Recordset ' Criterio = "SELECT COUNT(*) FROM " & NomeTabella rsTot.CursorLocation = adUseClient rsTot.Open Criterio, CnnSQL, adOpenForwardOnly, adLockReadOnly Tot = rsTot(0) rsTot.Close: Set rsTot = Nothing LbStato = LbStato & "Esamino " & NomeTabella & " (" & CStr(Tot) & " record)" & vbCrLf: LbStato.Refresh DoEvents strDelim = "'" Set rs = New ADODB.Recordset cnnIMP.Execute "DELETE FROM " & NomeTabella rs.Open NomeTabella, cnnMDB, adOpenStatic, adLockOptimistic TuttiCampi = "" TotCampi = rs.Fields.Count - 1 '===================================================================================== ATTENZIONE: SONO COSTRETTO A NON IMPORTARE PswDitta '''If NomeTabella = "TabPazienti" Then TotCampi = TotCampi - 1 '================================================================================================================================================== For i = 0 To TotCampi TuttiCampi = TuttiCampi & "[" & rs.Fields(i).Name & "]," Next i TuttiCampi = Left(TuttiCampi, Len(TuttiCampi) - 1) Do Criterio = "INSERT INTO " & NomeTabella & "(" & TuttiCampi & ")" Criterio = Criterio & " VALUES(" For i = 0 To TotCampi Select Case rs.Fields(i).Type Case adVarWChar, adLongVarWChar, adChar, adVarChar If Not IsNull(rs.Fields(i).value) Then S = Replace(rs.Fields(i).value, "'", "''") Criterio = Criterio & strDelim & S & strDelim & "," Else Criterio = Criterio & strDelim & strDelim & "," End If Case adDate strDate = Format(rs.Fields(i).value, "dd/mm/yyyy HH:MM:SS") Criterio = Criterio & strDelim & strDate & strDelim & "," Case adBoolean Select Case rs.Fields(i).value Case "Falso", "False": Criterio = Criterio & "0," Case "Vero", "True": Criterio = Criterio & "1," End Select Case adInteger, adDouble, adSingle, adInteger, adSmallInt, adCurrency, adUnsignedTinyInt If Not IsNull(rs.Fields(i)) Then V = rs.Fields(i).value Criterio = Criterio & CStr(V) & "," Else Criterio = Criterio & "0," End If Case Else Debug.Print rs.Fields(i).Name Debug.Print rs.Fields(i).Type Stop End Select Next i Mid$(Criterio, Len(Criterio), 1) = ")" cnnIMP.Execute Criterio rs.MoveNext Loop Until rs.EOF rs.Close: Set rs = Nothing End Sub

Rispondi quotando