473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stored Procedure from Access 97 to SQL 7

Hi Everyone,

I've got an Access application which has a link to an SQL 7 Server.

In my application I create a stored procedure which I send to the SQL
server via a passthrough query. I always end up with an error. If I
copy the created stored procedure to the query analyzer it works just
fine!

So I now think the problem is in my VBA-code.
This is the code I use to retrieve the desired recordset:

Dim db As Database
Dim strQuery As String
Dim qdefRapp As QueryDef

Set db = CurrentDb()
With CurrentDb.QueryDefs("qrySP_Rapportage")
.SQL = strSQL
.ODBCTimeout = 600
.Execute
End With

Set rstRapportage =
CurrentDb.QueryDefs("qrySP_Rapportage").OpenRecord set
At the Set rstRapportage I get an error which says: Invalid Operation.

Can anyone tell me what I is wrong here?

Thnx!
Nov 12 '05 #1
2 4620
You gave us everything except the SQL statement....

So, in lieu of the SQL statement, I'm only left to guess. Sometimes, depending
on the SQL, you need to send SET QUOTED_IDENTIFIER {ON | OFF} commands from a
pass-through.

strSQL = "SET QUOTED_IDENTIFIER ON "
strSQL = strSQL & "exec spHere"
strSQL = strSQL & " SET QUOTED_IDENTIFIER OFF"
Nov 12 '05 #2
ray_nl wrote:
Hi Everyone,

I've got an Access application which has a link to an SQL 7 Server.

In my application I create a stored procedure which I send to the SQL
server via a passthrough query. I always end up with an error. If I
copy the created stored procedure to the query analyzer it works just
fine!

So I now think the problem is in my VBA-code.
This is the code I use to retrieve the desired recordset:

Dim db As Database
Dim strQuery As String
Dim qdefRapp As QueryDef

Set db = CurrentDb()
With CurrentDb.QueryDefs("qrySP_Rapportage")
.SQL = strSQL
.ODBCTimeout = 600
.Execute
End With

Set rstRapportage =
CurrentDb.QueryDefs("qrySP_Rapportage").OpenRecord set
At the Set rstRapportage I get an error which says: Invalid Operation.

Can anyone tell me what I is wrong here?

Thnx!


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You set the variable "db," but don't use it! It might be better to do
this:

dim qd as dao.querydefs
set qd = db.QueryDefs("qrySP_Rapportage")

with qd
.SQL = strSQL
.ODBCTimeout = 600
.Execute
Set rstRapportage = .OpenRecordset
End With

I've found that sometimes if I don't use the object variables when
referring to items of the referred object's collection, the VBA code
doesn't work.

OT: Do you really want a 10 minute Time Out?

- --
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP4ZMcIechKqOuFEgEQJO+gCg1TUY7AwZOL/T+NiTZzKTQJBMtHAAoJjx
qa3DkZR4lxPnEuvi5GM1jHby
=y1YE
-----END PGP SIGNATURE-----

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: 8leggeddj | last post by:
Hello, I am having a problem when using access xp as a frontend for sql server 2000. I have been trying to update a number of stored procedures (Just simple adding fields etc) which results in...
2
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. ...
8
by: Mark Flippin | last post by:
This is for a reporting problem using: Access 2000 SQL Server 2000 Both at SP3 I've a stored procedure in SQL Server 2000 which builds a result set from a disparate set of tables, utilizing...
0
by: billmiami2 | last post by:
Perhaps many of you MS Access fanatics already know this, but it seems that stored procedures and views are possible in Jet. I thought I would leave this message just in case it would help anyone....
5
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
6
by: Peter Neumaier | last post by:
Hi, I am trying to select some data through a stored procedure and would like to store the result in a local access table. Is that possible? Can somebody provide an example? Thanks&regards!...
2
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
14
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
2
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.