• error in sql string preposition FROM

    Author
    Topic
    #463500

    Why….

    note:the filed have a blank into name

    SQL1 = “SELECT [DATA CENSIMENTO], [CODICE AGENZIA] FROM VERSAMENTI”
    RS.Open SQL1, cnDB, adOpenKeyset, adLockPessimistic, adCmdTable

    Viewing 0 reply threads
    Author
    Replies
    • #1183427

      You can only use adCmdTable to open a table, not for an SQL text string. Change adCmdTable to adCmdText.

      • #1183431

        You can only use adCmdTable to open a table, not for an SQL text string. Change adCmdTable to adCmdText.

        Hi frind is a good idea to loop the records and modify thaths with the sql in code.
        In effect i want to use the same value into record and update it with the value,….
        But have error…

        Code:
        Sub TEST_DATE_TAB()
        
        	On Error GoTo errore
        
        	Dim TEST As String
        	Set RS = New ADODB.Recordset
        
        	SQL1 = "SELECT [DATA CENSIMENTO],[CODICE AGENZIA] FROM VERSAMENTI"
        	RS.Open (SQL1), cnDB, adOpenKeyset, adLockPessimistic, adCmdText
        
        	RS.MoveFirst
        	Do While Not RS.EOF
        	
        		TEST = RS(0)
        		RS(0) = Right(TEST, 2) & "/" & Mid(TEST, 6, 2) & "/" & Left(TEST, 4)
        		TEST = RS(1)
        		RS(1) = Format((TEST * 1), "#0000")
        		
        	RS.Update
        		RS.MoveNext
        
        	Loop
        
        	RS.Close
        	Set RS = Nothing
        
        	Exit Sub
        
        errore:
        	MsgBox "Errore Numero: " & CStr(Err.Number) & vbCrLf & _
        		   "Descrizione: " & Err.Description & vbCrLf & _
        		   "Sorgente dell'Errore: " & Err.Source
        
        	Err.Clear
        
        	Application.ScreenUpdating = True
        	Application.Calculation = xlCalculationAutomatic
        
        End Sub
    Viewing 0 reply threads
    Reply To: error in sql string preposition FROM

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: