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

Why doesn't this code work???

Hello all,

I'm using an Access 97 front-end with a SQL Server 2000 back-end. One
particular bit of code runs a stored procedure to obtain a rowcount
from one of the back-end tables. This works fine on one PC, but not on
another. For the life of me, I can't see why it fails to work in the
'faulty' environment.

This is the code:-

Dim conImportCM As Connection
Dim wrkODBC As Workspace
Dim strConnection As String
Dim qdf As QueryDef

strConnection = "ODBC;DSN=ImportCM;Database=ImportCM; UID=xxxx;
PWD=yyyy"
Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
Set conImportCM = wrkODBC.OpenConnection("", dbDriverNoPrompt, ,
strConnection)
Set qdf = conImportCM.CreateQueryDef("", "{ ? = call
prcCountViewContract}")

qdf.Parameters(0).Direction = dbParamReturnValue
qdf.Execute

MsgBox "Row count is " & qdf.Parameters(0).Value

The stored procedure that's being executed is:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT ContractID FROM dbo.tblViewContract
RETURN @@ROWCOUNT
GO

This works fine on one PC running Windows 2000 and returns the expected
rowcount in the message box. On a another PC running Windows 98 SE, it
fails to return any data - the qdf.Parameters(0).Value returns null.

Initially, I thought it might be a permissions issue (because this is
running under a different user account on the two machines), but I can
fire-up MS Query on the Windows 98 machine and manually run the stored
procedure with 'exec prcCountViewContract' OK, so it looks like the
Windows 98 environment has the correct access to the SQL Server
back-end.

I've also updated MDAC on the Windows 98 machine so that it's the same
version as that used on the Windows 2000 PC (2.7). That has made
absolutely no difference to the symptoms.

Any ideas?

Thanks,

Mike

Nov 13 '05 #1
8 2575

Did you installl DCOM98 on the Win98 machine?

This should have been done before you installed MDAC.

--
Terry Kreft
MVP Microsoft Access
<mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello all,

I'm using an Access 97 front-end with a SQL Server 2000 back-end. One
particular bit of code runs a stored procedure to obtain a rowcount
from one of the back-end tables. This works fine on one PC, but not on
another. For the life of me, I can't see why it fails to work in the
'faulty' environment.

This is the code:-

Dim conImportCM As Connection
Dim wrkODBC As Workspace
Dim strConnection As String
Dim qdf As QueryDef

strConnection = "ODBC;DSN=ImportCM;Database=ImportCM; UID=xxxx;
PWD=yyyy"
Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
Set conImportCM = wrkODBC.OpenConnection("", dbDriverNoPrompt, ,
strConnection)
Set qdf = conImportCM.CreateQueryDef("", "{ ? = call
prcCountViewContract}")

qdf.Parameters(0).Direction = dbParamReturnValue
qdf.Execute

MsgBox "Row count is " & qdf.Parameters(0).Value

The stored procedure that's being executed is:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT ContractID FROM dbo.tblViewContract
RETURN @@ROWCOUNT
GO

This works fine on one PC running Windows 2000 and returns the expected
rowcount in the message box. On a another PC running Windows 98 SE, it
fails to return any data - the qdf.Parameters(0).Value returns null.

Initially, I thought it might be a permissions issue (because this is
running under a different user account on the two machines), but I can
fire-up MS Query on the Windows 98 machine and manually run the stored
procedure with 'exec prcCountViewContract' OK, so it looks like the
Windows 98 environment has the correct access to the SQL Server
back-end.

I've also updated MDAC on the Windows 98 machine so that it's the same
version as that used on the Windows 2000 PC (2.7). That has made
absolutely no difference to the symptoms.

Any ideas?

Thanks,

Mike

Nov 13 '05 #2
Terry,

No, I just installed MDAC 2.7 - I didn't see anything in the
documentation about installing DCOM first, and the MDAC installation
didn't complain at all. I've since checked the version of DCOM on the
Win 98SE machine - it is 'DCOM Win98 Gold 4.71.0.1719'.

Should I install DCOM98 1.3, or am I clutching at straws here?

Regards,

Mike

Terry Kreft wrote:
Did you installl DCOM98 on the Win98 machine?

This should have been done before you installed MDAC.

--
Terry Kreft
MVP Microsoft Access
<mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello all,

I'm using an Access 97 front-end with a SQL Server 2000 back-end. One particular bit of code runs a stored procedure to obtain a rowcount
from one of the back-end tables. This works fine on one PC, but not on another. For the life of me, I can't see why it fails to work in the 'faulty' environment.

This is the code:-

Dim conImportCM As Connection
Dim wrkODBC As Workspace
Dim strConnection As String
Dim qdf As QueryDef

strConnection = "ODBC;DSN=ImportCM;Database=ImportCM; UID=xxxx; PWD=yyyy"
Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
Set conImportCM = wrkODBC.OpenConnection("", dbDriverNoPrompt, , strConnection)
Set qdf = conImportCM.CreateQueryDef("", "{ ? = call
prcCountViewContract}")

qdf.Parameters(0).Direction = dbParamReturnValue
qdf.Execute

MsgBox "Row count is " & qdf.Parameters(0).Value

The stored procedure that's being executed is:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT ContractID FROM dbo.tblViewContract
RETURN @@ROWCOUNT
GO

This works fine on one PC running Windows 2000 and returns the expected rowcount in the message box. On a another PC running Windows 98 SE, it fails to return any data - the qdf.Parameters(0).Value returns null.
Initially, I thought it might be a permissions issue (because this is running under a different user account on the two machines), but I can fire-up MS Query on the Windows 98 machine and manually run the stored procedure with 'exec prcCountViewContract' OK, so it looks like the
Windows 98 environment has the correct access to the SQL Server
back-end.

I've also updated MDAC on the Windows 98 machine so that it's the same version as that used on the Windows 2000 PC (2.7). That has made
absolutely no difference to the symptoms.

Any ideas?

Thanks,

Mike


Nov 13 '05 #3
IIRC, Wni98se has DCOM pre-installed in which case you shouldn't need to
install it again, support articles on DCOM are at (watch for wrapping).

http://support.microsoft.com/search/...&srchExtraQry=
DCOM has to be installed on a machine for ADO to work, having to install
DCOM as a separate step is only an issue with Win95 and Win98 machines.
--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Terry,

No, I just installed MDAC 2.7 - I didn't see anything in the
documentation about installing DCOM first, and the MDAC installation
didn't complain at all. I've since checked the version of DCOM on the
Win 98SE machine - it is 'DCOM Win98 Gold 4.71.0.1719'.

Should I install DCOM98 1.3, or am I clutching at straws here?

Regards,

Mike

Terry Kreft wrote:
Did you installl DCOM98 on the Win98 machine?

This should have been done before you installed MDAC.

--
Terry Kreft
MVP Microsoft Access
<mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello all,

I'm using an Access 97 front-end with a SQL Server 2000 back-end. One particular bit of code runs a stored procedure to obtain a rowcount
from one of the back-end tables. This works fine on one PC, but not on another. For the life of me, I can't see why it fails to work in the 'faulty' environment.

This is the code:-

Dim conImportCM As Connection
Dim wrkODBC As Workspace
Dim strConnection As String
Dim qdf As QueryDef

strConnection = "ODBC;DSN=ImportCM;Database=ImportCM; UID=xxxx; PWD=yyyy"
Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
Set conImportCM = wrkODBC.OpenConnection("", dbDriverNoPrompt, , strConnection)
Set qdf = conImportCM.CreateQueryDef("", "{ ? = call
prcCountViewContract}")

qdf.Parameters(0).Direction = dbParamReturnValue
qdf.Execute

MsgBox "Row count is " & qdf.Parameters(0).Value

The stored procedure that's being executed is:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT ContractID FROM dbo.tblViewContract
RETURN @@ROWCOUNT
GO

This works fine on one PC running Windows 2000 and returns the expected rowcount in the message box. On a another PC running Windows 98 SE, it fails to return any data - the qdf.Parameters(0).Value returns null.
Initially, I thought it might be a permissions issue (because this is running under a different user account on the two machines), but I can fire-up MS Query on the Windows 98 machine and manually run the stored procedure with 'exec prcCountViewContract' OK, so it looks like the
Windows 98 environment has the correct access to the SQL Server
back-end.

I've also updated MDAC on the Windows 98 machine so that it's the same version as that used on the Windows 2000 PC (2.7). That has made
absolutely no difference to the symptoms.

Any ideas?

Thanks,

Mike

Nov 13 '05 #4
Definitely clutching at straws now...

The version of DCOM98 on the Windows 98SE PC wasn't the 'latest and
greatest' so I installed 1.3. It didn't make any difference at all.
The qdf.Parameters(0).Value still returns null instead of the expected
row count. Identical code runs fine on my Windows 2000 PC.

Any more ideas anyone? ...or is this one of those cases where the
quickest solution is going to be a re-write to get the row count in a
different way?

Thanks,

Mike

Nov 13 '05 #5
Mike,
Looking at your original post again, I would have written the SP as

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT(*) FROM dbo.tblViewContract

--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Definitely clutching at straws now...

The version of DCOM98 on the Windows 98SE PC wasn't the 'latest and
greatest' so I installed 1.3. It didn't make any difference at all.
The qdf.Parameters(0).Value still returns null instead of the expected
row count. Identical code runs fine on my Windows 2000 PC.

Any more ideas anyone? ...or is this one of those cases where the
quickest solution is going to be a re-write to get the row count in a
different way?

Thanks,

Mike

Nov 13 '05 #6
Terry,

I changed the stored procedure to:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT (*) FROM dbo.tblViewContract
RETURN @Rows
GO

.... and it works fine now. Thanks very much for your help!

Regards,

Mike

Terry Kreft wrote:
Mike,
Looking at your original post again, I would have written the SP as

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT(*) FROM dbo.tblViewContract

--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Definitely clutching at straws now...

The version of DCOM98 on the Windows 98SE PC wasn't the 'latest and
greatest' so I installed 1.3. It didn't make any difference at all. The qdf.Parameters(0).Value still returns null instead of the expected row count. Identical code runs fine on my Windows 2000 PC.

Any more ideas anyone? ...or is this one of those cases where the quickest solution is going to be a re-write to get the row count in a different way?

Thanks,

Mike


Nov 13 '05 #7
BTW, you do realise that the RETURN statement is meant to return a value
indicating success or failure and that normally it returns 0 to indicate
success?

I think your VBA code should be

Dim wrkODBC As Workspace
Dim strConnection As String
Dim qdf As QueryDef

strConnection = "ODBC;DSN=ImportCM;Database=ImportCM;
UID=xxxx;PWD=yyyy"
Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
Set conImportCM = wrkODBC.OpenConnection("", dbDriverComplete, ,
strConnection)

' ***************************
' NOTE DIFFERENCE HERE
Set qdf = conImportCM.CreateQueryDef("", "{? = call
prcCountViewContract(?)}")

qdf.Parameters(0).Direction = dbParamReturnValue
qdf.Parameters(1).Direction = dbParamReturnValue
qdf.Execute

MsgBox "Success is " & (qdf.Parameters(0).Value > 0)
MsgBox "Row count is " & qdf.Parameters(1).Value

--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Terry,

I changed the stored procedure to:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT (*) FROM dbo.tblViewContract
RETURN @Rows
GO

... and it works fine now. Thanks very much for your help!

Regards,

Mike

Terry Kreft wrote:
Mike,
Looking at your original post again, I would have written the SP as

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT(*) FROM dbo.tblViewContract

--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Definitely clutching at straws now...

The version of DCOM98 on the Windows 98SE PC wasn't the 'latest and
greatest' so I installed 1.3. It didn't make any difference at all. The qdf.Parameters(0).Value still returns null instead of the expected row count. Identical code runs fine on my Windows 2000 PC.

Any more ideas anyone? ...or is this one of those cases where the quickest solution is going to be a re-write to get the row count in a different way?

Thanks,

Mike

Nov 13 '05 #8
Terry,

Thanks for the clarification. I guess it comes as no surprise to you
that I'm a bit new to the use of SPs from Access. I think that was a
bit of playing "guess the syntax" on my part! Time to get the manuals
out....

At least it all works now. Thanks again for all your help. Much
appreciated.

Regards,

Mike

Terry Kreft wrote:
BTW, you do realise that the RETURN statement is meant to return a value indicating success or failure and that normally it returns 0 to indicate success?

I think your VBA code should be

Dim wrkODBC As Workspace
Dim strConnection As String
Dim qdf As QueryDef

strConnection = "ODBC;DSN=ImportCM;Database=ImportCM;
UID=xxxx;PWD=yyyy"
Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
Set conImportCM = wrkODBC.OpenConnection("", dbDriverComplete, ,
strConnection)

' ***************************
' NOTE DIFFERENCE HERE
Set qdf = conImportCM.CreateQueryDef("", "{? = call
prcCountViewContract(?)}")

qdf.Parameters(0).Direction = dbParamReturnValue
qdf.Parameters(1).Direction = dbParamReturnValue
qdf.Execute

MsgBox "Success is " & (qdf.Parameters(0).Value > 0)
MsgBox "Row count is " & qdf.Parameters(1).Value

--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Terry,

I changed the stored procedure to:-

CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT (*) FROM dbo.tblViewContract
RETURN @Rows
GO

... and it works fine now. Thanks very much for your help!

Regards,

Mike

Terry Kreft wrote:
Mike,
Looking at your original post again, I would have written the SP as
CREATE PROCEDURE prcCountViewContract
@Rows int = NULL OUTPUT
AS
SELECT @Rows = COUNT(*) FROM dbo.tblViewContract

--
Terry Kreft
MVP Microsoft Access
"MikeH" <mh****@bigfoot.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
> Definitely clutching at straws now...
>
> The version of DCOM98 on the Windows 98SE PC wasn't the 'latest and > greatest' so I installed 1.3. It didn't make any difference at

all.
> The qdf.Parameters(0).Value still returns null instead of the

expected
> row count. Identical code runs fine on my Windows 2000 PC.
>
> Any more ideas anyone? ...or is this one of those cases
where the
> quickest solution is going to be a re-write to get the row
count in a
> different way?
>
> Thanks,
>
> Mike
>


Nov 13 '05 #9

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

Similar topics

11
by: Julian | last post by:
Hi I have code in my login.asp which sets the online field in user database to true or 1. I am trying to use the same code in global.asa to change back the online field to 0 but it doesn't work....
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
6
by: benb | last post by:
I have form that looks a lot like a search bar for the user to search for records matching specified criteria (e.g. first names containing "ben"). For robust results, an intermediary form displays...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
4
by: bbp | last post by:
Hello, In an ASPX page I have a "Quit" button which make a simple redirect in code-behind. This button doesn't work no more since (I think) I moved from the framework 1.0 to 1.1 and it doesn't...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
6
by: Johnny Jörgensen | last post by:
I've got a usercontrol derived from a normal ComboBox that contains some special formatting code. On my main form I've got a lot of my custom comboboxes. I discovered a bug in the derived...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
20
by: cmrchs | last post by:
Hi, I have in my web application project (VS.NET 2008) : - a webform (webform2.aspx, webform2.aspx.cs, webform2.aspx.designer.cs) - a code-file Product.cs. But i can't use the definition of...
0
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
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
marktang
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,...
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
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.