Reputation: 127
I have a problem as the topic. Run-error 3708 and my code break on append parameters line. Where I make a mistake? Table in oracle have only this 4 columns.
Sub Export(path As String)
...
Set insertCmnd = New ADODB.Command
With insertCmnd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = "INSERT INTO DEVCRM.COK_WE_REZYGNACJA_KO (IMIĘ, NAZWISKO, PESEL, NAZWISKO_RODOWE_MATKI) " _
+ "VALUES(:IMIĘ,:NAZWISKO,:PESEL,:NAZWISKO_RODOWE_MATKI)"
.Prepared = True
End With
Set prmpNAME = insertCmnd.CreateParameter(name:=":IMIĘ", Type:=adLongVarChar)
Set prmpSURNAME = insertCmnd.CreateParameter(name:=":NAZWISKO", Type:=adLongVarChar)
Set prmpPESEL = insertCmnd.CreateParameter(name:=":PESEL", Type:=adLongVarChar)
Set prmpNRM = insertCmnd.CreateParameter(name:=":NAZWISKO_RODOWE_MATKI", Type:=adLongVarChar)
With insertCmnd.Parameters
.Append prmpNAME **here is a break**
.Append prmpSURNAME
.Append prmpPESEL
.Append prmpNRM
End With
cn.BeginTrans
Do Until excelRecords.EOF
prmpNAME.Value = excelRecords.Fields("IMIĘ").Value
prmpSURNAME.Value = excelRecords.Fields("NAZWISKO").Value
prmpPESEL.Value = excelRecords.Fields("PESEL").Value
prmpNRM.Value = excelRecords.Fields("NAZWISKO_RODOWE_MATKI").Value
insertCmnd.Execute
excelRecords.MoveNext
Loop
cn.CommitTrans
cn.Close
End Sub
Thanks for a help!
Upvotes: 2
Views: 8490
Reputation: 21
When creating a parameter, ensure that the size defined in SQL is mentioned in the .CreateParameter("",adVarchar,10,value)
Upvotes: 1
Reputation: 743
You have to specify the Size
parameter when calling CreateParameter
.
The following doesn't cause error 3708 for me:
CreateParameter(name:=":IMIE;", Type:=adLongVarChar, Size:=1)
Upvotes: 7