MS Access报告使用参数将查询传递给SQL Server

时间:2022-06-14 15:43:25

I have a PDF report that opens when one clicks on a form button. Recently we've had to migrate the db to SQL Server. I have a stored procedure in SQL Server that requires one argument and I'm trying to access the stored procedure from Ms Access front end. Anyone knows how to go about this; from the syntax of the Pass Through Query to the report's code for opening. Any help will be gladly appreciated.

我有一个PDF报告,只需点击一个表单按钮就会打开。最近我们不得不将数据库迁移到SQL Server。我在SQL Server中有一个存储过程,需要一个参数,我正在尝试从Ms Access前端访问存储过程。任何人都知道如何去做;从Pass Through Query的语法到报告的打开代码。任何帮助将不胜感激。

1 个解决方案

#1


0  

I'm assuming you are not still using pre-2007 Access.....

我假设你还没有使用2007年之前的Access .....

Access 2007
On the Create tab, click Query Design in the Other group.
Click Close in the Show Table dialog box without adding any tables or queries. 
On the Design tab, click Pass-Through in the Query Type workgroup.
Click Property Sheet in the Show/Hide workgroup to display the property sheet for the query.
In the query property sheet, place the mouse pointer in the
ODBC Connect Str property, and then, click the Build (...) button.

With the ODBC Connect Str property, you specify information about the database to which you want to connect. You can type the connection information, or click Build, and then enter information about the server to which you are connecting.
When you are prompted to save the password in the connection string, click Yes if you want the password and logon name to be stored in the connection string information.
If the query is not the type that returns records, set the ReturnsRecords property to No.
In the SQL Pass-Through Query window, type your pass-through query. For example, the following pass-through query uses the Microsoft SQL Server TOP operator in the SELECT statement to return only the first 25 orders in the Orders table from the sample Northwind database:
SELECT TOP 25 orderid from orders
To run the query, click Run in the Results group on the Design tab. For a SQL pass-through query that returns records, click Datasheet view on the status bar.
If necessary, Microsoft Access prompts you for information about your server database.

#1


0  

I'm assuming you are not still using pre-2007 Access.....

我假设你还没有使用2007年之前的Access .....

Access 2007
On the Create tab, click Query Design in the Other group.
Click Close in the Show Table dialog box without adding any tables or queries. 
On the Design tab, click Pass-Through in the Query Type workgroup.
Click Property Sheet in the Show/Hide workgroup to display the property sheet for the query.
In the query property sheet, place the mouse pointer in the
ODBC Connect Str property, and then, click the Build (...) button.

With the ODBC Connect Str property, you specify information about the database to which you want to connect. You can type the connection information, or click Build, and then enter information about the server to which you are connecting.
When you are prompted to save the password in the connection string, click Yes if you want the password and logon name to be stored in the connection string information.
If the query is not the type that returns records, set the ReturnsRecords property to No.
In the SQL Pass-Through Query window, type your pass-through query. For example, the following pass-through query uses the Microsoft SQL Server TOP operator in the SELECT statement to return only the first 25 orders in the Orders table from the sample Northwind database:
SELECT TOP 25 orderid from orders
To run the query, click Run in the Results group on the Design tab. For a SQL pass-through query that returns records, click Datasheet view on the status bar.
If necessary, Microsoft Access prompts you for information about your server database.