473,406 Members | 2,633 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.

better syntax for following simple statement...

I have a dataset, objDSet, returning one scalar value.

I am currently using the following...

Dim rRow As DataRow = objDSet.Tables(0).Rows(0)

If rRow("UserCount") <0 Then (do something)

but I would prefer to put it all on one line if possible...

e.g.

If objDSet.Tables(0).Rows("UserCount") ...

is this possible?
--

fiddlewidawiddum
Nov 10 '06 #1
3 919
Of course you can. You can do something like:

If objDSet.Tables(0).Rows(0)("UserCount") <0 Then ...

This implies you have option strict off, since you are getting an Object out
of the datarow, but you are comparing it to 0. You should always turn
option strict on, and make it the default for any new projects.

"Stimp" <re*@spumco.comwrote in message
news:sl****************@murphy.redbrick.dcu.ie...
>I have a dataset, objDSet, returning one scalar value.

I am currently using the following...

Dim rRow As DataRow = objDSet.Tables(0).Rows(0)

If rRow("UserCount") <0 Then (do something)

but I would prefer to put it all on one line if possible...

e.g.

If objDSet.Tables(0).Rows("UserCount") ...

is this possible?
--

fiddlewidawiddum

Nov 10 '06 #2
On Fri, 10 Nov 2006 Marina Levit [MVP] <so*****@nospam.comwrote:
Of course you can. You can do something like:

If objDSet.Tables(0).Rows(0)("UserCount") <0 Then ...

This implies you have option strict off, since you are getting an Object out
of the datarow, but you are comparing it to 0. You should always turn
option strict on, and make it the default for any new projects.
so it's not possible to do with Option Strict On though?
>
"Stimp" <re*@spumco.comwrote in message
news:sl****************@murphy.redbrick.dcu.ie...
>>I have a dataset, objDSet, returning one scalar value.

I am currently using the following...

Dim rRow As DataRow = objDSet.Tables(0).Rows(0)

If rRow("UserCount") <0 Then (do something)

but I would prefer to put it all on one line if possible...

e.g.

If objDSet.Tables(0).Rows("UserCount") ...

is this possible?
--

fiddlewidawiddum


--

fiddlewidawiddum
Nov 10 '06 #3
You can, you just have to explicity cast the result to an integer.

In general, having Option Strict Off is a very bad programming practice. It
leads to many runtime errors that could have been caught at compile time. It
also makes code harder to read.

"Stimp" <re*@spumco.comwrote in message
news:sl****************@murphy.redbrick.dcu.ie...
On Fri, 10 Nov 2006 Marina Levit [MVP] <so*****@nospam.comwrote:
>Of course you can. You can do something like:

If objDSet.Tables(0).Rows(0)("UserCount") <0 Then ...

This implies you have option strict off, since you are getting an Object
out
of the datarow, but you are comparing it to 0. You should always turn
option strict on, and make it the default for any new projects.

so it's not possible to do with Option Strict On though?
>>
"Stimp" <re*@spumco.comwrote in message
news:sl****************@murphy.redbrick.dcu.ie. ..
>>>I have a dataset, objDSet, returning one scalar value.

I am currently using the following...

Dim rRow As DataRow = objDSet.Tables(0).Rows(0)

If rRow("UserCount") <0 Then (do something)

but I would prefer to put it all on one line if possible...

e.g.

If objDSet.Tables(0).Rows("UserCount") ...

is this possible?
--

fiddlewidawiddum



--

fiddlewidawiddum

Nov 10 '06 #4

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
41
by: John Marshall | last post by:
How about the following, which I am almost positive has not been suggested: ----- class Klass: def __init__(self, name): self.name = name deco meth0: staticmethod def meth0(x):
8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
59
by: seberino | last post by:
I've heard 2 people complain that word 'global' is confusing. Perhaps 'modulescope' or 'module' would be better? Am I the first peope to have thought of this and suggested it? Is this a...
177
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are...
27
by: Adam Warner | last post by:
Hi all, In the code snippet below I successfully determine the address of val1:* struct o val1=l_SYM_2B(&a).o; print_aesthetic(&val1); The structure o is heavyweight. I understand...
3
by: Neil Zanella | last post by:
Hello, I am trying to execute ADO.NET INSERT statement where one of the fields is coming from a password HTML control. When I access the text with password.Value and print with Response.Write...
12
by: Brad Baker | last post by:
I am trying to write a simple ASP.net/C# page which allows users to select some values and produce a report based on a SQL query. I have a self posting dropdown form which allows users to select...
16
by: Chuck | last post by:
Please help me correct the statements in sub "BoundData" The following sub is in a module. Everything runs with no error messages, however,data is not reaching the text box. Data is being...
3
by: BreckCogdill | last post by:
Hello, I'm trying to modify some code in simple Forum script - adding an ID field to an insert statement. I have added the field to the d/b & now I'm trying to add this new field to the existing...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
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.