473,698 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to handle, when SQL command returns a single value

Hi,

I have a problem in dealing with the return value of the SQL command. I know how to do, when SQL command returns Recordsets. But in my case it returns a single value. The following code fails when "objRst.ope n strQ" is executed. Can somebody suggest me how to overcome this problem.

Any Help is appreciated.
Thanks in advance,
Vasanth
-----------------------
Set objConnect = Server.CreateOb ject("ADODB.Con nection")
objConnect.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & mdbFilePath & ";"
Set objRst = Server.CreateOb ject("ADODB.Rec ordset")
strQ = "Select MAX(index) from library where index like '*B-*';"
objRst.Open strQ
cmd.execute
while Not objRst.EOF
index=objRst("i ndex")
objrst.movenext
Wend
Set objRst = nothing
objConnect.Clos e
Set objConnect = nothing
%>
<html>
<head>
<title>
</title>
</head>
<body>
<form action="newupda te.asp" method=post>
index:<%=index% >
</form>
</body>
</html>
----------------------------------------
I also tried the following alternative. Here it fails when I try to print "objRst" on the page.
Set objConnect = Server.CreateOb ject("ADODB.Con nection")
objConnect.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & mdbFilePath & ";"
Set cmd = Server.CreateOb ject("ADODB.Com mand")
Set cmd.ActiveConne ction = objConnect
strQ = "Select MAX(index) from library where index like '*B-*';"
cmd.commandtext =strQ
set objRst = cmd.execute
objConnect.Clos e
Set objConnect = nothing
%>
<html>
<head>
<title>
</title>
</head>
<body>
<form action="newupda te.asp" method=post>
index:<%=objRst %>
</form>
</body>
</html>
Jul 19 '05 #1
2 2303
The problem is that you do not have a column named INDEX in your recordset.
You have an unnamed column that represents MAX(index). You can either name
it in your query or use the index value in the recordset to get it. (Not
the same "index" as in your column name.)

"Select MAX(index) as TheMax from library..."
index = objRst.Fields.I tem("TheMax").V alue

Or, leave your query as is and do:

index = objRst.Fields.I tem(0).Value

Ray at work

"vasanth kumar" <va***********@ eds.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi,

I have a problem in dealing with the return value of the SQL command. I
know how to do, when SQL command returns Recordsets. But in my case it
returns a single value. The following code fails when "objRst.ope n strQ" is
executed. Can somebody suggest me how to overcome this problem.

Any Help is appreciated.
Thanks in advance,
Vasanth
-----------------------
Set objConnect = Server.CreateOb ject("ADODB.Con nection")
objConnect.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
mdbFilePath & ";"
Set objRst = Server.CreateOb ject("ADODB.Rec ordset")
strQ = "Select MAX(index) from library where index like '*B-*';"
objRst.Open strQ
cmd.execute
while Not objRst.EOF
index=objRst("i ndex")
objrst.movenext
Wend
Jul 19 '05 #2
Thanks for the help. It worked.

-Vasanth
"Ray at <%=sLocation% > [MVP]" <myfirstname at lane34 dot com> wrote in
message news:OH******** *****@TK2MSFTNG P12.phx.gbl...
The problem is that you do not have a column named INDEX in your recordset. You have an unnamed column that represents MAX(index). You can either name it in your query or use the index value in the recordset to get it. (Not
the same "index" as in your column name.)

"Select MAX(index) as TheMax from library..."
index = objRst.Fields.I tem("TheMax").V alue

Or, leave your query as is and do:

index = objRst.Fields.I tem(0).Value

Ray at work

"vasanth kumar" <va***********@ eds.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi,

I have a problem in dealing with the return value of the SQL command. I know how to do, when SQL command returns Recordsets. But in my case it
returns a single value. The following code fails when "objRst.ope n strQ" is executed. Can somebody suggest me how to overcome this problem.

Any Help is appreciated.
Thanks in advance,
Vasanth
-----------------------
Set objConnect = Server.CreateOb ject("ADODB.Con nection")
objConnect.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
mdbFilePath & ";"
Set objRst = Server.CreateOb ject("ADODB.Rec ordset")
strQ = "Select MAX(index) from library where index like '*B-*';"
objRst.Open strQ
cmd.execute
while Not objRst.EOF
index=objRst("i ndex")
objrst.movenext
Wend

Jul 19 '05 #3

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

Similar topics

0
3541
by: iKiLL | last post by:
Hi All Code Below for this problem ERROR: "An existing connection was forcibly closed by the remote host"
9
3010
by: PengYu.UT | last post by:
Hi, I feel argparse has some useful things that optparse doesn't have. But I can't find it argparse in python library reference. I'm wondering when it will be available in the python standard installation. Thanks, Peng
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.