473,418 Members | 1,757 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,418 software developers and data experts.

ADO command causes recordset field to return null?

I have the strangest error, and wonder if anyone else has seen it. I'm
using ADODB to return a set of SQL Server 2005 records via ODBC. If I
open the recordset this way

With cmd
.CommandType = adCmdStoredProc
.CommandText = "dbo.spMyProc"
Set prm = .CreateParameter("@ID", adInteger,
Value:=plngID)
.Parameters.Append prm
Set prm = .CreateParameter("@A", adBoolean, Value:=pbleA)
.Parameters.Append prm
Set prm = .CreateParameter("@B", adBoolean, Value:=pbleB)
.Parameters.Append prm

.ActiveConnection = mcnn
Set rst = .Execute
'same problem with rst.Open cmd
End With

a date/time field in the resultset is null, or as nullish as can be
determined. If I run the same thing this way

With rst
.Source = "EXEC dbo.spMyProc " & plngID & ", " &
IIf(pbleA, "1", "0") & ", " & IIf(pbleB, "1", "0")
.CursorType = adOpenStatic

.ActiveConnection = mcnn
.Open
End With

the date field is populated properly.

Has anyone else seen a bug like this? I've never seen it before--I use
setups like the first one all the time--and I can't find anything
about it on the internet(s) either.

Aug 27 '07 #1
5 4047
If you have the abitlity to run stored procedures on Sql Server then you
have the ability to connect via OLEDB. Don't use ODBC -- that is
probably where your problems is originating. Here is an OLEDB
connection sample

cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourServer;Database=YourDB;Trusted_Connecti on=Yes"
cmd.ActiveConnection.CursorLocation = adUseClient
cmd.CommandTimeout = 600
cmd.CommandType = adCmdStoredProc

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 27 '07 #2
I should probably convince my client to switch to OLEDB. Using DSNs
allows for rapid change of environment during dev, is the only reason
I can think of that the connection is still made via ODBC, though it's
my understanding that using ADO actually makes the point moot.

The magic parameter, actually, is the CursorLocation--as soon as I
specify adUseClient in the command, it works properly, using ODBC. I
didn't know how where to do this in a command, but it's also my
understanding that this can be costly when working with large
datasets, and is generally to be avoided. Plus, switching to the
client should hardly turn a null value back into a date. I don't see
the source of the error.

On Aug 27, 3:25 pm, Rich P <rpng...@aol.comwrote:
If you have the abitlity to run stored procedures on Sql Server then you
have the ability to connect via OLEDB. Don't use ODBC -- that is
probably where your problems is originating. Here is an OLEDB
connection sample

cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourServer;Database=YourDB;Trusted_Connecti on=Yes"
cmd.ActiveConnection.CursorLocation = adUseClient
cmd.CommandTimeout = 600
cmd.CommandType = adCmdStoredProc

Rich

*** Sent via Developersdexhttp://www.developersdex.com***

Aug 27 '07 #3
If performing an RDBMS operation correctly reduces the performance of
your system -- you need to re-evaluate the tools you are using. Access
was revolutionary in its early days because it was one of the first (if
not the first) RDBMS on the market -- with the added feature of an
integrated development environment within the RDBMS. But it has long
since been supersceded by improved technology for handling large
datasets, multi-user environments, web environments, multi-tiered
systems (which would mostly be enterprise systems).

With the newer technologies and newer times, Enterprise systems
want/need MORE capabilities than the Access model can deliver
(effectively). It turns out that the integrated Development environment
within the RDBMS (Access) was not as effective for large data/user
operations than a separate RDBMS/Development system (thus the .Net/sql
server paradigm was born). The .Net environment has significantly
overcome a lot of the obstacles/short commings of the Access model that
enterprise systems have encountered as they demand MORE of everything.

For single user single workstation operations, Access would be more
efficient that an enterprise system (less overkill). But if the word
multi-user/Network/Web comes into the picture you really should be
thinking .Net with Sql Server.

It seems like alot of developers who have been working with Access for
10 or more years have been resisting the migration to .Net. Over at my
place, I am the only person with 10+ years of RDBMS experience and the
only person who even touches Access. All the younger guys here (mostly
right out of college) are using .Net/Ruby/...Pearl seems to be making a
comeback. But even I can't keep up with these younger guys. I made it
to .Net which is at least good for enterprise stuff. So, what I would
do in your scenario is to re-evaluate the needs of your company.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 27 '07 #4
Sorry, I don't really follow what you're saying. I see virtually no
performance difference between SQLOLEDB and ODBC, nor was that causing
my problem; I mentioned in passing that it would be worth getting my
client to switch over, but it's hardly a priority, or even a
necessity.

My only question, at the moment, is over CursorLocation, and Access
works just fine with a server-side cursor almost all the time--in
fact, this is the first time I've seen an error in data that I could
trace to using a server-side cursor. I'm asking *how* using a client-
side cursor can somehow rectify whatever ADO bugginess might cause a
recordset to come down with an inexplicably empty column.

As for .NET, I'm perfectly at home in it, but I'm also the rare young
guy who still knows Access, and I just try to save clients money by
modeling their apps in Access until they know what they want. As has
been stated in this newsgroup repeatedly, and as I see in my work
every day and even more prominently in the work of my .NET-exclusive
colleagues, .NET is still much slower to build in. Even without using
bound forms etc.
On Aug 27, 5:29 pm, Rich P <rpng...@aol.comwrote:
If performing an RDBMS operation correctly reduces the performance of
your system -- you need to re-evaluate the tools you are using. Access
was revolutionary in its early days because it was one of the first (if
not the first) RDBMS on the market -- with the added feature of an
integrated development environment within the RDBMS. But it has long
since been supersceded by improved technology for handling large
datasets, multi-user environments, web environments, multi-tiered
systems (which would mostly be enterprise systems).

With the newer technologies and newer times, Enterprise systems
want/need MORE capabilities than the Access model can deliver
(effectively). It turns out that the integrated Development environment
within the RDBMS (Access) was not as effective for large data/user
operations than a separate RDBMS/Development system (thus the .Net/sql
server paradigm was born). The .Net environment has significantly
overcome a lot of the obstacles/short commings of the Access model that
enterprise systems have encountered as they demand MORE of everything.

For single user single workstation operations, Access would be more
efficient that an enterprise system (less overkill). But if the word
multi-user/Network/Web comes into the picture you really should be
thinking .Net with Sql Server.

It seems like alot of developers who have been working with Access for
10 or more years have been resisting the migration to .Net. Over at my
place, I am the only person with 10+ years of RDBMS experience and the
only person who even touches Access. All the younger guys here (mostly
right out of college) are using .Net/Ruby/...Pearl seems to be making a
comeback. But even I can't keep up with these younger guys. I made it
to .Net which is at least good for enterprise stuff. So, what I would
do in your scenario is to re-evaluate the needs of your company.

Rich

*** Sent via Developersdexhttp://www.developersdex.com***

Aug 27 '07 #5
>>
As for .NET, I'm perfectly at home in it, but I'm also the rare young
guy who still knows Access, and I just try to save clients money by
modeling their apps in Access until they know what they want. As has
been stated in this newsgroup repeatedly, and as I see in my work every
day and even more prominently in the work of my .NET-exclusive
colleagues, .NET is still much slower to build in. Even without using
bound forms etc.
<<

Sorry bout the drama. But as you say - when the client knows what the
client wants. Where you sort of lose me is that if you can connect to
sql server with ODBC and run SPs, then can't you connect with OLEDB? Or
is it a permission thing? You should be able to write a connection
string like my sample and run it.

Try a basic select count(*) from some table statement

Dim cmd As New ADODB.Command, RS As New ADODB.Recordset
...
cmd.CommandText = "Select count(*) from someTbl"
Set RS = cmd.Execute
Debug.Print RS(0)

IF this doesn't work, then it is a permission thing. But it should
work. If it does work, then run that by your client. ODBC for Access
is quite old technology with low bandwidth and limited capabilities
compared to OLEDB.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 27 '07 #6

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

Similar topics

7
by: Keith | last post by:
What is the correct code to use to hide a section if a specific DB field is NULL. Thanks
1
by: Richard | last post by:
I need to dynamically add (but not remove) vectors of doubles based on keys/names. Please see my code below. Am I reinventing the wheel or doing anything inefficiently? I get the feeling that I am,...
0
by: Brad | last post by:
Hi all, I've never come across this one before and am hoping someone may be able to shed some light on a very strange situation. I'm using a DNS less connection and a ADO recordset to retrieve...
4
by: Marie | last post by:
My report has a text field named ItemNum. Most records have a value for ItemNum. I set Grouping And Sorting to sort ascending on the ItemNum field. The records where ItemNum is Null appear at the...
6
by: Mike | last post by:
In VB I have a recordset and want to work with specific fields. I realize I can use an index number e.g. rst(23)but I don't like using index numbers in case I change the underlying fields or...
3
by: Daves | last post by:
a get { ... } for public property SelectedValue returns DateTime type to be used as a parameter in a Sql update query but I'd like it to return "empty" if no date has been selected... I cannot use...
9
by: Francois Grieu | last post by:
When running the following code under MinGW, I get realloc(p,0) returned NULL Is that a non-conformance? TIA, Francois Grieu #include <stdio.h> #include <stdlib.h>
14
by: alnino | last post by:
Hi, I have a command button on a form that the user can use to browse to a file and the user can select that file and a hyperlink to that file is stored in a txtfield for that record. I then...
7
by: Calvin Dent | last post by:
Hi Guys, I have a probably relatively simple problem to fix but cannot seem to work it out. The Function I have is If DateField = Date -1 Then ValueField = "1" End if
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
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
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.