gpt4 book ai didi

ms-access - 微软 Access : No value given for one or more required parameters

转载 作者:行者123 更新时间:2023-12-02 01:01:00 25 4
gpt4 key购买 nike

我正在尝试对 MS Access 数据库运行以下查询(从 .asp 页面):

SELECT firstname, lastname, emp_id FROM employees ORDER BY firstname

但是,我得到一个错误提示

No value given for one or more required parameters.

Now, the query runs fine if I exclude the "emp_id" (primary key) field. I have made sure that the field exists and that there are no typos in the query.

If I run the query through the MS Access GUI, there's a pop-up asking me to enter a "parameter value" for the emp_id field. Could this be why it won't work, and why does it happen?

Getting the employees from the db:

Function GetEmployees()

Dim employeesRS, sqlGetEmployees, employeesList, e

Set employeesList = CreateObject("System.Collections.ArrayList")

sqlGetEmployees = "SELECT firstname, lastname, emp_id FROM employees ORDER BY firstname"

Set employeesRS = db.connTb.execute(sqlGetEmployees) 'Custom class to simplify db-querying

While Not employeesRS.EOF

Set e = new Employee

e.Firstname = employeesRS("firstname")
e.Lastname = employeesRS("lastname")
e.Id = employeesRS("emp_id")

employeesList.Add(e)

employeesRS.MoveNext
Wend

employeesRS.Close

Set GetEmployees = employeesList

End Function

表结构的屏幕截图:(您可能已经注意到,我在帖子中翻译了表和代码,以使其更具可读性。代码/表字段之间的关系是相同的。)

enter image description here

最佳答案

已解决:

MS Access中的查询结果 View 显示字段名称为“emp_id”,但实际名称为“employee_id”。

使用数据库的程序曾经是一个 Access-forms 应用程序,因此在查询结果 View 中的列上的名称与实际名称不同(出于某种原因,我不知道为什么这听起来是个好主意)

关于ms-access - 微软 Access : No value given for one or more required parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28601913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com