473,406 Members | 2,293 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,406 software developers and data experts.

type argument in OpenRecordset method

The questions are toward the bottom of this post.

Situation is this:
1) Access 97
2) Multi-user appplication
3) SQL Server 2000
4) Sporadically (i.e. less than 1% of the time) encounter the
following error:

3218 Couldn't update; currently locked

in a particular function (function name is
GetFullyQualifiedTableName).

The code from the GetFullyQualifiedTableName function is below:

*** code begins on next line ***
Dim rst As recordSet
Dim strExec As String
GetFullyQualifiedTableName = ""
' there is a stored proc on SQL Server named
uspDummyGetFullyQualifiedTableName
strExec = "EXEC dbo.uspDummyGetFullyQualifiedTableName "
' GetStandardParmams returns a string, the contents of which are
the parameters that get sent
' to the stored proc
strExec = strExec & GetStandardParams()

' the value of qdfReusable is established outside this function;
qdfReusable is:
' - a querydef object
' - where the .Connect property is an ODBC connection

' set the .SQL property of the querydef to the string that gets
created in the code above
qdfReusable.SQL = strExec
qdfReusable.ReturnsRecords = True
' Session.PassThruQryName is a string the contents of which is the
name of qdfReusable
Set rst = CurrentDB.OpenRecordset(Session.PassThruQryName)
GetFullyQualifiedTableName = rst.Fields(0)
rst.Close
*** code ends on previous line ***

The fact that

Questions:
1) Is it likely that the 3218 exception is happening on the call to
the OpenRecordset method?
2) Rather than relying on a default value, if I were to supply an
explicit value in the type argument of the OpenRecordset method, might
that eliminate the 3218 error? If so, would you recommend a value in
the type argument of dbOpenSnapshot?
3) the Help fiile within MS Access tells me what the valid values that
may be supplied in the type argument, but it seems a bit sparse as far
as suggesting: "in this type of envirnoment, you should specify the
following value in the type argument..." can you point me to some
reference material that offers a 'best practice' advice for setting
the value of the type argument in the OpenRecordset method?

Thank you.
Sep 19 '08 #1
7 11035
For efficiency reasons you should always open the least-functional recordset
that you need.

Since you are using SQL Server linked tables, you have a choice of three:

dbOpenForwardOnly: recordset can't be updated, and you can't navigate in it
except to iterate forwards from beginning to end.
dbOpenSnapshot: recordset can't be updated, but you can navigate in it.
dbOpenDynaset: recordset is updatable and fully navigable (this is the
default).

In your case, since the recordset apparently only returns one record and you
don't need to update it, dbOpenForwardOnly should do the job.

However, I am far from convinced that this is the cause of your problem.
The error you are getting is an obscure Access error and my guess is that it
has nothing to do with locking in the SQL Server database (particularly
since you appear to be doing nothing which updates the database) and is
something to do with locking in your Access front-end file, perhaps when you
try to update the SQL property of the query. Presumably you have some kind
of error handling which tells you that this is the procedure where the error
occurs: if so, it would be a good idea to enhance it to report the line
number where the error occurs.

Does each user have their own copy of your Access front-end, or are they
sharing the same file? If the latter, this is a bad idea and you should
distribute a "local" copy to each user. Does the front-end get regularly
compacted/repaired?

<mi************@yahoo.comwrote in message
news:98**********************************@y38g2000 hsy.googlegroups.com...
The questions are toward the bottom of this post.

Situation is this:
1) Access 97
2) Multi-user appplication
3) SQL Server 2000
4) Sporadically (i.e. less than 1% of the time) encounter the
following error:

3218 Couldn't update; currently locked

in a particular function (function name is
GetFullyQualifiedTableName).

The code from the GetFullyQualifiedTableName function is below:

*** code begins on next line ***
Dim rst As recordSet
Dim strExec As String
GetFullyQualifiedTableName = ""
' there is a stored proc on SQL Server named
uspDummyGetFullyQualifiedTableName
strExec = "EXEC dbo.uspDummyGetFullyQualifiedTableName "
' GetStandardParmams returns a string, the contents of which are
the parameters that get sent
' to the stored proc
strExec = strExec & GetStandardParams()

' the value of qdfReusable is established outside this function;
qdfReusable is:
' - a querydef object
' - where the .Connect property is an ODBC connection

' set the .SQL property of the querydef to the string that gets
created in the code above
qdfReusable.SQL = strExec
qdfReusable.ReturnsRecords = True
' Session.PassThruQryName is a string the contents of which is the
name of qdfReusable
Set rst = CurrentDB.OpenRecordset(Session.PassThruQryName)
GetFullyQualifiedTableName = rst.Fields(0)
rst.Close
*** code ends on previous line ***

The fact that

Questions:
1) Is it likely that the 3218 exception is happening on the call to
the OpenRecordset method?
2) Rather than relying on a default value, if I were to supply an
explicit value in the type argument of the OpenRecordset method, might
that eliminate the 3218 error? If so, would you recommend a value in
the type argument of dbOpenSnapshot?
3) the Help fiile within MS Access tells me what the valid values that
may be supplied in the type argument, but it seems a bit sparse as far
as suggesting: "in this type of envirnoment, you should specify the
following value in the type argument..." can you point me to some
reference material that offers a 'best practice' advice for setting
the value of the type argument in the OpenRecordset method?

Thank you.

Sep 20 '08 #2
On Sep 19, 11:21*pm, "bcap" <b...@nospam.nowherewrote:
Since you are using SQL Server linked tables, you have a choice of three:

dbOpenForwardOnly: recordset can't be updated, and you can't navigate in it
except to iterate forwards from beginning to end.
dbOpenSnapshot: recordset can't be updated, but you can navigate in it.
dbOpenDynaset: recordset is updatable and fully navigable (this is the
default).

In your case, since the recordset apparently only returns one record and you
don't need to update it, dbOpenForwardOnly should do the job.
I didn't mention this in the original post (and I don't think it
changes the information/advice above regarding which value to choose
in the type argument of the OpenRecordset) but in case it is, in fact,
relevant, I'll mention it here because I noticed a reference to
'...linked tables':

The Access app does NOT have any linked tables. The Access app calls
a stored proc, and that sproc performs a SQL Server 2000 SELECT
statement from a SQL SERVER 2000 table...that SELECT statement returns
the result set back to the Access app. But if one were to look at the
Tables tab of the Database window of the MS Access app, one would not
see any linked tables.
However, I am far from convinced that this is the cause of your problem.
The error you are getting is an obscure Access error and my guess is thatit
has nothing to do with locking in the SQL Server database (particularly
since you appear to be doing nothing which updates the database)
....correct...no updates going on
and is something to do with locking in your Access front-end file, perhaps when you
try to update the SQL property of the query. *Presumably you have some kind
of error handling which tells you that this is the procedure where the error
occurs:
....correct...the function has ON ERROR logic that informs me that the
error happened somewhere within the function
if so, it would be a good idea to enhance it to report the line number where the error occurs.
....yes, that is a good idea. I know how to do that in a "brute force"
manner, e.g. by:
a) updating a variable after each line successfully executes
b) having the exception handling code display the contents of
the variable
but I was wondering whether MS Access provides a more elegant way for
me to do that...is there some built-in value that identifies the
specific line on which the error occurred?
Does each user have their own copy of your Access front-end, or are they
sharing the same file? *
It's more like the former than the latter. The application is
distributed to multiple servers across the company network, so it
resembles the "each user has their own copy", but there may be more
than one user of the application from the same server...there are not,
however, a large number of users sharing the same app on any given
server. The most active server has about a dozen users sharing that
application, but it's never the case that there are more than 3 or 4
users on at any given time, and it's usually the case that there is
usually zero or one user on at any given time.
If the latter, this is a bad idea and you should
distribute a "local" copy to each user. *Does the front-end get regularly
compacted/repaired?
The front-end gets compacted/repaired about once every other month.

Thank you.

Sep 22 '08 #3
JvC
I am not sure if this will solve your problem, but I would do the
following:
Don't use CurrentDB. I have found that it occasionally "flakes out".
Use a Database variable. Be explicit.

Dim db as DAO.Database

If this needs to be an updatable recordset, use:
Set rst = db.OpenRecordset(Session.PassThruQryName, dbOpenDynaset,
dbSeeChanges)

If it does not need to be updatabale use:
Set rst = db.OpenRecordset(Session.PassThruQryName,
dbOpenSnapshot)

John

mi************@yahoo.com wrote on 9/19/2008 :
The questions are toward the bottom of this post.

Situation is this:
1) Access 97
2) Multi-user appplication
3) SQL Server 2000
4) Sporadically (i.e. less than 1% of the time) encounter the
following error:

3218 Couldn't update; currently locked

in a particular function (function name is
GetFullyQualifiedTableName).

The code from the GetFullyQualifiedTableName function is below:

*** code begins on next line ***
Dim rst As recordSet
Dim strExec As String
GetFullyQualifiedTableName = ""
' there is a stored proc on SQL Server named
uspDummyGetFullyQualifiedTableName
strExec = "EXEC dbo.uspDummyGetFullyQualifiedTableName "
' GetStandardParmams returns a string, the contents of which are
the parameters that get sent
' to the stored proc
strExec = strExec & GetStandardParams()

' the value of qdfReusable is established outside this function;
qdfReusable is:
' - a querydef object
' - where the .Connect property is an ODBC connection

' set the .SQL property of the querydef to the string that gets
created in the code above
qdfReusable.SQL = strExec
qdfReusable.ReturnsRecords = True
' Session.PassThruQryName is a string the contents of which is the
name of qdfReusable
Set rst = CurrentDB.OpenRecordset(Session.PassThruQryName)
GetFullyQualifiedTableName = rst.Fields(0)
rst.Close
*** code ends on previous line ***

The fact that

Questions:
1) Is it likely that the 3218 exception is happening on the call to
the OpenRecordset method?
2) Rather than relying on a default value, if I were to supply an
explicit value in the type argument of the OpenRecordset method, might
that eliminate the 3218 error? If so, would you recommend a value in
the type argument of dbOpenSnapshot?
3) the Help fiile within MS Access tells me what the valid values that
may be supplied in the type argument, but it seems a bit sparse as far
as suggesting: "in this type of envirnoment, you should specify the
following value in the type argument..." can you point me to some
reference material that offers a 'best practice' advice for setting
the value of the type argument in the OpenRecordset method?

Thank you.

Sep 22 '08 #4
Hi again,

You are correct, the advice is not affected, dbOpenForwardOnly is still the
one you need in this situation.

The VBA function "Erl" returns the line number where the most recent error
occurred. You will need to number all your lines, but that shouldn't be too
great a hardship if the procedure is not large.

Having any users sharing a front-end file is a bad idea, but in your case
it's doubly bad because of the way you are using "qdfreusable". There is
every possibility that your users are colliding over the use of this query
object.

<mi************@yahoo.comwrote in message
news:b5**********************************@2g2000hs n.googlegroups.com...
On Sep 19, 11:21 pm, "bcap" <b...@nospam.nowherewrote:
Since you are using SQL Server linked tables, you have a choice of three:

dbOpenForwardOnly: recordset can't be updated, and you can't navigate in
it
except to iterate forwards from beginning to end.
dbOpenSnapshot: recordset can't be updated, but you can navigate in it.
dbOpenDynaset: recordset is updatable and fully navigable (this is the
default).

In your case, since the recordset apparently only returns one record and
you
don't need to update it, dbOpenForwardOnly should do the job.
I didn't mention this in the original post (and I don't think it
changes the information/advice above regarding which value to choose
in the type argument of the OpenRecordset) but in case it is, in fact,
relevant, I'll mention it here because I noticed a reference to
'...linked tables':

The Access app does NOT have any linked tables. The Access app calls
a stored proc, and that sproc performs a SQL Server 2000 SELECT
statement from a SQL SERVER 2000 table...that SELECT statement returns
the result set back to the Access app. But if one were to look at the
Tables tab of the Database window of the MS Access app, one would not
see any linked tables.
However, I am far from convinced that this is the cause of your problem.
The error you are getting is an obscure Access error and my guess is that
it
has nothing to do with locking in the SQL Server database (particularly
since you appear to be doing nothing which updates the database)
....correct...no updates going on
and is something to do with locking in your Access front-end file, perhaps
when you
try to update the SQL property of the query. Presumably you have some kind
of error handling which tells you that this is the procedure where the
error
occurs:
....correct...the function has ON ERROR logic that informs me that the
error happened somewhere within the function
if so, it would be a good idea to enhance it to report the line number
where the error occurs.
....yes, that is a good idea. I know how to do that in a "brute force"
manner, e.g. by:
a) updating a variable after each line successfully executes
b) having the exception handling code display the contents of
the variable
but I was wondering whether MS Access provides a more elegant way for
me to do that...is there some built-in value that identifies the
specific line on which the error occurred?
Does each user have their own copy of your Access front-end, or are they
sharing the same file?
It's more like the former than the latter. The application is
distributed to multiple servers across the company network, so it
resembles the "each user has their own copy", but there may be more
than one user of the application from the same server...there are not,
however, a large number of users sharing the same app on any given
server. The most active server has about a dozen users sharing that
application, but it's never the case that there are more than 3 or 4
users on at any given time, and it's usually the case that there is
usually zero or one user on at any given time.
If the latter, this is a bad idea and you should
distribute a "local" copy to each user. Does the front-end get regularly
compacted/repaired?
The front-end gets compacted/repaired about once every other month.

Thank you.
Sep 22 '08 #5
On Sep 22, 11:56*am, "bcap" <b...@nospam.nowherewrote:
The VBA function "Erl" returns the line number where the most recent error
occurred. *You will need to number all your lines, but that shouldn't be too
great a hardship if the procedure is not large.
Thank you...that looks like it will be a very helpful tool/utility.
Having any users sharing a front-end file is a bad idea, but in your case
it's doubly bad because of the way you are using "qdfreusable". *There is
every possibility that your users are colliding over the use of this query
object.
Apologies...I didn't put all the implementation details in the
original post or the follow up post...specifically, I failed to
include an important detail about how collisions are avoided. There
is no possibility of the type of collision about which you warned.
The reasons for this are:
1) at the beginning of the session (when app user opens the app), the
app calls NT_GetUserName in advapi32.dll
2) NT_GetUserName returns a value that differs for each user
3) when the app instantiates the qdfreusable querydef object, it
includes the results of NT_GetUserName in the name of the querydef
object
So, for example, if there were a dozen users simultaneously using the
application, there would be a dozen differently-named querydef objects
instantiated.

Thanks for the information...if I'm interpreting the replies
correctly, it sounds as though it's still a bit of a mystery as to why
the 3218 error is occurring.

Sep 23 '08 #6
It's *still* a bad idea to have users sharing a front-end, and I'm still
willing to bet that this is the cause of your problem, whether or not
qdfreusable is at the root of it.

Finding out what line the problem is occurring on will be important.
<mi************@yahoo.comwrote in message
news:88**********************************@26g2000h sk.googlegroups.com...
On Sep 22, 11:56 am, "bcap" <b...@nospam.nowherewrote:
The VBA function "Erl" returns the line number where the most recent error
occurred. You will need to number all your lines, but that shouldn't be
too
great a hardship if the procedure is not large.
Thank you...that looks like it will be a very helpful tool/utility.
Having any users sharing a front-end file is a bad idea, but in your case
it's doubly bad because of the way you are using "qdfreusable". There is
every possibility that your users are colliding over the use of this query
object.
Apologies...I didn't put all the implementation details in the
original post or the follow up post...specifically, I failed to
include an important detail about how collisions are avoided. There
is no possibility of the type of collision about which you warned.
The reasons for this are:
1) at the beginning of the session (when app user opens the app), the
app calls NT_GetUserName in advapi32.dll
2) NT_GetUserName returns a value that differs for each user
3) when the app instantiates the qdfreusable querydef object, it
includes the results of NT_GetUserName in the name of the querydef
object
So, for example, if there were a dozen users simultaneously using the
application, there would be a dozen differently-named querydef objects
instantiated.

Thanks for the information...if I'm interpreting the replies
correctly, it sounds as though it's still a bit of a mystery as to why
the 3218 error is occurring.
Sep 24 '08 #7
On Sep 19, 2:35*pm, mirandacasc...@yahoo.com wrote:
GetFullyQualifiedTableName).
The fully qualified table name precisely identifies the table:
Server.Database.Schema.Name

If one doesn't know the fully qualified table name then how could one
be sure he/she is getting the fully qualified table name of the
correct table?

I suppose one might not know the Schema or Owner, but as there could
be identically named tables in various databases on the same server
surely one would have to know the database name?

This cannot (unless our connection defaults to a specific database)
find the table and returns no records:
SELECT
[so].[name] AS TableName
,[ss].[name] AS SchemaName
FROM
[sys].[objects]
AS so
INNER JOIN
[sys].[schemas]
AS ss
ON
[so].[schema_id] = [ss].[schema_id]
WHERE [so].[type] = 'U'
AND [so].[name] = 'Schools'

This can:

SELECT
[so].[name] AS TableName
,[ss].[name] AS SchemaName
FROM
[FFDBA-LAPTOP\SONYLAPTOP].[FFDBA_ESO].[sys].[objects]
AS so
INNER JOIN
[FFDBA-LAPTOP\SONYLAPTOP].[FFDBA_ESO].[sys].[schemas]
AS ss
ON
[so].[schema_id] = [ss].[schema_id]
WHERE [so].[type] = 'U'

So can this:

USE [FFDBA_ESO]

SELECT
[so].[name] AS TableName
,[ss].[name] AS SchemaName
FROM
[sys].[objects]
AS so
INNER JOIN
[sys].[schemas]
AS ss
on
[so].[schema_id] = [ss].[schema_id]
WHERE [so].[type] = 'U'
AND [so].[name] = 'Schools'
AND [so].[name] = 'Schools'
Sep 25 '08 #8

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

Similar topics

0
by: Bobbak | last post by:
Hello All, I could really use some help with this bit of code I am working on, every time I come to execute it I get an error that says "Compile Error: Argument not optional". Now I am using...
42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
8
by: Richard Hollenbeck | last post by:
I have two functions (one using the other) where I want to pass into it the character A, B, C, D, or F and have it return a Double indicating the minimum score it takes to get that grade. For...
3
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a...
5
by: Sunnyrain | last post by:
I am developing a program in Access 2000. I couldn't make OpenRecordset method work right. It's working when I opened a simple SQL query below in OpenRecordset. ..... Dim dbs As Database, rst...
1
by: jnikle | last post by:
I have a parameter query named "qry_employee_info_reports" that I need to run in the OnOpen event of a form. I'm after its total number of records. The query's got several joins in it, and one of...
4
by: Harold Howe | last post by:
I am running into a situation where the compiler complains that it cannot infer the type parameters of a generic method when one of the function arguments is an anonymous method. Here is a...
4
by: tomlebold | last post by:
Why do I receive a Type mismatch error when running the following code, which has a SQL Server 2000 back end database? The error occurs on the following line: Set rs = db.OpenRecordset(SQL,...
4
by: sheperson | last post by:
Hi, I have a stored procedure in my database and it has an argument of type output (int). When I create a dataset using VS2005, it creates a table adapter for me and the Fill method has and...
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?
1
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...
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
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,...
0
isladogs
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...

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.