I already found two ways to call an MSSQL stored procedure form MS Access:
1) Pass through query
Problem: Every client has to configure the DNS-source, I don't want that, too much administration work...
2) Write VBA code (e.g. using ADO object)
Problem: I don't want another connection.
I already linked the MS Access database with SSMA. Why can't I use this connection to call a stored procedure?
Hopefully there's an easy solution...Thanks in advance
Best regards,
D.R.
Edit: MS Access 2007
@Poweruser
Each linked table will have a connection string (property) associated with it then. This can be seen using the VBA IDE by typing : - ? CurrentDB.TableDefs("linked table name").Connect
in the Immediate pane (Ctrl-G). Alternatively, the Linked Table Manager will show this for each linked table in your database I believe. @Poweruser
Another alternative is to avoid the wizard and either type, or paste in, the string directly. I don't use 2007, but 2003 instead, but I doubt there is much difference in this respect. @Poweruser
This works on using a similar string to that which you use in your linked tables. It doesn't link via your tables. There is no DSN stored within your database. The string, whatever it is, must use some form of DSN, whether it by file held, or in your registry (System Data Source). I suspect, given that you are already using connected tables, that there must be a usable DSN defined somewhere for you to reference.
I hope you find this helpful.
12 9938
Nobody knows how to call an MSSQL stored procedure from MS access? :(
What's the best approach?
Best regards,
D.R.
To the best of my knowledge, there are 5 Methods for Executing Stored Procedures via a Microsoft Access Project: - From the Access Database Container
- From another Stored Procedure
- From a Pass-Through Query
- From ADO using a Command Object
- From DAO
NeoPa 32,556
Expert Mod 16PB @Poweruser
What do you mean specifically by 'the DNS-source'?
Connections can be stored as a property of the PassThru query itself, so I'm struggling to see a problem here. Maybe because I don't know what you mean by the relatively loose term 'DNS-source' above. @Poweruser
What is this? Standard Access or something 3rd-party?
You wouldn't be expected to know as a new member, but we like people to wait at least 24 hours before bumping a thread. All our volunteers have lives and none of us guarantees to be available every day (Weekends are generally particularly quiet - mainly because there are so much fewer questions and responses to deal with).
Last, but not least, Welcome to Bytes!
Sorry for early bumping my thread, I was frustrated!
SSMA = Microsoft SQL Server Migration Assistant for Access 4.0
I used the tool to migrate all my access tables to MSSQL server. I want to use that same connection to call MSSQL stored procedures / functions.
Connections can be stored as a property of the PassThru query itself, so I'm struggling to see a problem here.
Really? I'm using Access 2007 when I want to change the "ODBC Connect Str" property of a PassThru query, I get the "Select Data Source" dialog -> I can choose either a file data source or a machine data source. Nothing embedded in my access application :(
@ADezii: Which do you think is the fastest way? Becasue performance is the main reason I want to use stored procedures.
How to call a stored procedure "From the Access Database Container"?
Best regards,
D.R.
NeoPa 32,556
Expert Mod 16PB @Poweruser
Each linked table will have a connection string (property) associated with it then. This can be seen using the VBA IDE by typing : - ? CurrentDB.TableDefs("linked table name").Connect
in the Immediate pane (Ctrl-G). Alternatively, the Linked Table Manager will show this for each linked table in your database I believe. @Poweruser
Another alternative is to avoid the wizard and either type, or paste in, the string directly. I don't use 2007, but 2003 instead, but I doubt there is much difference in this respect. @Poweruser
This works on using a similar string to that which you use in your linked tables. It doesn't link via your tables. There is no DSN stored within your database. The string, whatever it is, must use some form of DSN, whether it by file held, or in your registry (System Data Source). I suspect, given that you are already using connected tables, that there must be a usable DSN defined somewhere for you to reference.
I hope you find this helpful.
NeoPa 32,556
Expert Mod 16PB @NeoPa
It appears that, while the LTM does show some information for each linked table, it doesn't necessarily include all the data. I would certainly recommend using the former method for discovering the correct working .Connect property value.
Thank you very much!
I used the VBA immediate pane to get the ODBC string (other people reading this thread: don't forget the '?' in the beginning...)
Then Copy&Paste this string to the Pass through query's ODBC Connect Str property.
Finished!
Somebody knows if this is the fastest way for calling stored procedures? At least it seems to be a very easy way.
Thank you again!
Best regards,
D.R.
NeoPa 32,556
Expert Mod 16PB
You're welcome. @Poweruser
It's the most direct.
If the SP returns a Cursor (a recordset essentially), you can link to that as a table too, but if you want work done on MS SQL Server that involves executing your SQL code (a simple EXEC of the SP doesn't really benefit that much) then PassThrus are the most efficient ways of doing this I believe.
One important item to keep in mind is that Pass-Through Queries provide no mechanism for dealing with Output Parameters or the Return Value of a Stored Procedure.
NeoPa 32,556
Expert Mod 16PB @ADezii
Check out the properties of a PassThru query. You're looking particularly for : - Returns Records
- Log Messages
Not the same as Output Parameters and Return Values, are they?
NeoPa 32,556
Expert Mod 16PB
No. They're not exactly. You're right.
I inferred from the context you were talking more generally about returning the values produced by a Stored Procedure. It's true that such values cannot be passed back directly to VBA calling code.
The Return Value is accessible, as can any Output Parameters, but only by directing them to a table within the SQL. They are certainly not as easy to process as local procedures.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft...
|
by: robin via SQLMonster.com |
last post by:
I've tried several different way to execute a oracle stored
procedure from a DTS package but to no avail.
I have a Linked Server setup which does bring back Oracle tables from the
server when I...
|
by: Chris |
last post by:
Hello everyone
I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1
It has 4 parameters, the 1st and the 4th are OUTPUT and the others are INPUT
params.
My code looks like this:...
|
by: Jean-Marc Blaise |
last post by:
Dear all,
I have simulated the windows MULTI application with a java program calling
the SQLTP1DL proc referenced as DB2DARI application, on Linux Intel or
ZLinux. If the proc is NOT FENCED,...
|
by: mxd |
last post by:
We have server 2003 with sql 2000. as a client getting data from an IBM
iseries server with DB2 UDB. The connection is through a linked sever with
ODBC connection to DB2. If we invoke a SQL stored...
|
by: Lyle Fairfield |
last post by:
I created a new MS-SQL Database, "TestODBC".
I made Table1 and StoredProcedure1.
I made an ODBC DSN for that MS-SQL Database.
I created a new AccessXP mdb, "TestODBC".
I linked to the...
|
by: Lauren Quantrell |
last post by:
I have read the newsgroups and see this is a common issue but I saw no
resolution for it:
I have an Access2K frotn end and SQL Server 2K backend.
In access, I create a temp table using code in a...
|
by: fumanchu |
last post by:
I've got to let end users (really just one person) load billing batch
files into a third party app table. They need to specify the billing
cycle name, the batch name, and the input file name and...
|
by: Pedro Vera |
last post by:
I am helping somebody setup one of the asp.net starter kits. I
converted it from sql express to sql server with no real issues, and I
got it running local perfectly.
On my first attempt to run...
|
by: barmatt80 |
last post by:
I don't know if this is the right part of the forum. But.... I have been working all night trying to create a web service to call a stored procedure in sql server 2008. The stored procedure calls...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |