运行时错误"3061"; :参数太少,预期为1 [英] run time error "3061" : too few parameters, expected 1

查看:350
本文介绍了运行时错误"3061"; :参数太少,预期为1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB6(32位-1998)错误3061-Windows 7-访问2007-EXCEL 2007

VB6 (32 BIT - 1998) ERROR 3061 - WINDOWS 7 - ACCESS 2007 - EXCEL 2007

我编写了一个VB6程序,该程序从ACCESS 2007数据库中提取记录并将其写入EXCEL 2007工作表中.

I wrote a VB6 program that extracts records from an ACCESS 2007 database and writes them into an EXCEL 2007 sheet.

程序运行正常,我使用了exe几个月.然后,发生了混乱. 我安装为"C"的新1GB HD自杀并出现了永久性错误. 我的第二个2 GB"D"也同时出现了永久性错误. 再见系统.

The program worked fine and I used the exe for several months. Then, mayhem happended. A new 1GB HD I installed as "C" commited suicide and developed a permanent error. My secondary 2 GB "D" also developed a simultaneous permanent error. Bye bye system.

我能够恢复一切.放入新的硬盘驱动器(保修提供).从CD重新安装了W7,ACCESS 2007,EXCEL 2007和VB6.

I was able to recover everything. Put in new hard driveS (warranty provided them). Reinstalled W7, ACCESS 2007, EXCEL 2007 and VB6, all from CD.

现在,当我运行VB exe时,出现运行时错误3061-参数太少-预期至少为1.

Now, when I run my VB exe, gives me runtime error 3061 - too few parameters - at least 1 was expected.

罪魁祸首是选择:

Set rs = db.OpenRecordset(Select_str)

选择内容:

SELECT
    HORA,
    ARL,
    ARL_ECON,
    ESTADO_OPE,
    EST_REMUN,
    ENERGIA,
    POT_DISP,
    POT_RECORTADA,
    PIND,
    PINDFORZ,
    CGN,
    CGO,
    CFO,
    CCM,
    PRECIO_NODO,
    PR_REM_ENERGIA,
    SCTD,
    SCO,
    COSTO_406,
    COMPRA_SPOT,
    POT_DISP_RESERVA,
    POT_DISP_GAS,
    GAS_NOMINADO,
    REM_ADICIONAL,
    REM_ADIC_TOTAL,
    DESP_ECON,
    PGENE_COMP_446,
    REM_ADIC_COMP_446,
    REM_GAS_6866,
    REMUN_ADIC_6866,
    POT_DISP_ACD
FROM VALORES_GENERADORES
WHERE GRUPO = "XXXXXX"

我通过以下方式构建选择:

I build the select this way:

BeguinSelectString$ = "SELECT HORA, "
DE$ = " FROM "
Donde$ = " WHERE GRUPO = " + Chr(34)
FinDelSelect$ = Chr(34) + " "

Select_str = ""

'我使用FOR/NEXT构建此选择,以列出所有字段并将其放入选择中.

' I BUILD THIS SELECT WITH A FOR/NEXT TO LIST ALL FIELDS AND PUT THEM IN THE SELECT.

Select_str = BeguinSelectString$

For i = 0 To (Max_Index_de_Records_1 - 1)

    Select_str = Select_str + Nombres_de_Campos_1(i) + ", "

Next i

    Select_str = Select_str + Nombres_de_Campos_1(Max_Index_de_Records_1) ' I INSERT THE LAST FIELD WITHOUT THE COMMA, ELSE IT GIVES AN ERROR

    Select_str = Select_str + _
             DE$ + _
             Tabla + _
             Donde$ + _
             sNombre_del_Grupo + _
             FinDelSelect$

项目引用按以下顺序排列:

THE PROJECT REFERENCES ARE, in this order:

  1. 应用程序的Visual Basic
  2. Visual Basic运行时对象和过程
  3. Visual Basic对象和过程
  4. ActiveBar控件
  5. ActiveEx类型库
  6. Microsoft DAO 3.6对象库
  7. Microsoft Excel 12.0对象库
  8. Microsoft Access 12.0对象库
  9. Microsoft Office 12.0对象库

推荐答案

如果您确定问题中的SELECT语句是您的代码构建的 exact语句,请复制该文本,在Access查询设计器中创建一个新查询,切换到SQL视图,粘贴复制的文本并尝试运行它.

If you're certain the SELECT statement in your question is the exact statement built by your code, copy that text, create a new query in the Access query designer, switch to SQL View, paste in the copied text and try to run it.

Access将显示一个参数输入框,要求您提供参数值.请注意,该框包含名称" ,而Access认为该参数都是该参数.该参数名称是某些内容(通常是拼写错误的字段名称),在VALORES_GENERADORES表中找不到Access.由于找不到名称,因此假定名称必须是参数.

Access will present a parameter input box asking you to supply a value for the parameter. Notice that box includes the "name" of whatever Access thinks is the parameter. That parameter name is something (often a misspelled field name) Access can't find in the VALORES_GENERADORES table. Since it can't find the name, it assumes the name must be a parameter.

这篇关于运行时错误"3061"; :参数太少,预期为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆