VBA 参数对象定义不正确。提供了不一致或不完整的信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25423475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 04:19:25  来源:igfitidea点击:

VBA Parameter object is improperly defined. Inconsistent or incomplete information was provided

vbaparametersadodb

提问by caruzo

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.

我有一个问题作为主题。运行错误 3708 和我的代码在追加参数行中断。我哪里出错了?oracle中的表只有这4列。

    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!

感谢您的帮助!

回答by gebi

You have to specify the Sizeparameter when calling CreateParameter.

Size调用时必须指定参数CreateParameter

The following doesn't cause error 3708 for me:

以下不会对我造成错误 3708:

CreateParameter(name:=":IMIE;", Type:=adLongVarChar, Size:=1)

回答by ABCD

When creating a parameter, ensure that the size defined in SQL is mentioned in the .CreateParameter("",adVarchar,10,value)

创建参数时,请确保.CreateParameter("",adVarchar, 10,value)中提到了SQL中定义的大小