Pble de syntaxe

Fermé
didi29 - 23 juin 2008 à 14:04
 didi29 - 23 juin 2008 à 14:29
Bonjour,
j'ai un soucis de syntaxe et je ne trouve pas ,c la grosse galere
si qq sais svp
voila mon bou de code :

SQL_U = "UPDATE SAFIG " & _
"SET IDREMISE = " & rs("Idremise") & "," & _
"SET perimetre = " & rs("perimetre") & "," & _
"SET DateRemise2 = " & rs("DateRemise2") & "," & _
"SET Vacation = " & rs("Vacation") & "," & _
"SET FileInteg = " & rs("FilInteg") & "," & _
"SET FileCloture = " & rs("FileCloture") & "," & _
"SET Restitution = " & rs("Restitution") & "," & _
"SET MotifRejet = " & rs("MotifRejet") & "," & _
"SET DestRejet = " & rs("DestRejet") & "," & _
"SET Adresse1 = " & rs("Adresse1") & "," & _
"SET Adresse2 = " & rs("Adresse2") & "," & _
"SET Adresse3 = " & rs("Adresse3") & "," & _
"SET Adresse4 = " & rs("Adresse4") & "," & _
"SET Centre = " & rs("Centre") & "," & _
"SET Origine = " & rs("Origine") & "," & _
"SET RefAXA = " & rs("RefAXA") & "," & _
"SET URL = " & rs("URL") & "," & _
"SET Lignes = " & rs("Lignes") & "," & _
"SET Pages = " & rs("Pages") & "," & _
"SET EnCours = " & rs("EnCours & "WHERE Clé = " & rs.Clé & ";"

2 réponses

donuts08 Messages postés 519 Date d'inscription dimanche 13 novembre 2005 Statut Membre Dernière intervention 15 octobre 2008 39
23 juin 2008 à 14:07
salut,

si c'est bien une requête de base de données en SQL ton problème est qu'il ne faut pas épéter les "SET" il faut en mettre qu'un.
0
merci,mais ca ne marche pas ; je veux faire un module en vba sous access pour MAJ d'une bd selon un fichier qu'on m'envoi tt les jours ,je mets mon code sans les set de depart mais c pareil ,il me met une erreur "erreur d'execution 3265 elmt non trouvé ds cette collection"
si tu peux faire qqc
merci;

Option Compare Database


Sub TestMAJ2()
Dim wrk As Workspace
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim SQL As String
Dim SQL_S, SQL_U, SQL_I As String
Set wrk = DBEngine.Workspaces(0)
Set db = DBEngine.OpenDatabase("D:\SAFIG\SAFIG.mdb")
SQL = "SELECT * FROM Import ;"
Set rs = db.OpenRecordset(SQL, dbOpenForwardOnly, dbReadOnly)
Do While Not rs.EOF

MsgBox (rs("Clé"))

SQL_S = "SELECT Clé FROM SAFIG where Clé =" & rs("Clé") & ";"
Set conn = CurrentProject.Connection
conn.Execute SQL

If Not (rs.EOF Or rs.BOF) Then

'Si clé trouvée, Requête pour UPDATE dans SAFIG
SQL_U = "UPDATE SAFIG " & _
"SET IDREMISE = " & rs("Idremise") & "," & _
" perimetre = " & rs("perimetre") & "," & _
" DateRemise2 = " & rs("DateRemise2") & "," & _
" Vacation = " & rs("Vacation") & "," & _
" FileInteg = " & rs("FilInteg") & "," & _
" FileCloture = " & rs("FileCloture") & "," & _
" Restitution = " & rs("Restitution") & "," & _
" MotifRejet = " & rs("MotifRejet") & "," & _
" DestRejet = " & rs("DestRejet") & "," & _
" Adresse1 = " & rs("Adresse1") & "," & _
" Adresse2 = " & rs("Adresse2") & "," & _
" Adresse3 = " & rs("Adresse3") & "," & _
" Adresse4 = " & rs("Adresse4") & "," & _
" Centre = " & rs("Centre") & "," & _
" Origine = " & rs("Origine") & "," & _
" RefAXA = " & rs("RefAXA") & "," & _
" URL = " & rs("URL") & "," & _
" Lignes = " & rs("Lignes") & "," & _
" Pages = " & rs("Pages") & "," & _
" EnCours = " & rs("EnCours") & "WHERE Clé = " & rs("Clé") & ";"
MsgBox ("update" & SQL_U)
Else
'Requête pour insertion dans SAFIG

SQL_I = "INSERT INTO SAFIG SELECT Import.* FROM Import WHERE Clé=" & rs("Clé") & ";"

MsgBox ("insert" & SQL_I)
End If
rs.MoveNext
Loop


End Sub
0