473,464 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ADO C# VB Difference

In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T
May 13 '06 #1
10 1564
No. That's the way to do it.
--

Cheers,
Gaurav
http://www.edujini.in
-------------------
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:ez****************@TK2MSFTNGP05.phx.gbl...
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T

May 13 '06 #2
I suppose you could shave off a line:

dsLogin.CustLoginRow theRow= (dsLogin.CustLoginRow)
dsLogin1.CustLogin.Rows[0];

Actually, if you think C# is "Wordy", try counting the number of characters
in an entire Class written in VB.NET and then the same one in C#. Most of the
time, C# is more compact. It certainly is more elegant, although that of
course is just my opinion.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T

May 13 '06 #3
Thanks. That's a little better.

Regarding your preference for C#....

IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this difference
thing. Microsoft should have flipped a coin and just put all of there
resources on either one of them.

T


"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:E9**********************************@microsof t.com...
I suppose you could shave off a line:

dsLogin.CustLoginRow theRow= (dsLogin.CustLoginRow)
dsLogin1.CustLogin.Rows[0];

Actually, if you think C# is "Wordy", try counting the number of
characters
in an entire Class written in VB.NET and then the same one in C#. Most of
the
time, C# is more compact. It certainly is more elegant, although that of
course is just my opinion.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T

May 13 '06 #4
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this
difference thing. Microsoft should have flipped a coin and just put all
of there resources on either one of them.


LOL! I guess you don't work in marketing... :-)
May 13 '06 #5
I am proud to say that I certainly don't work in Marketing (I passed
calculus).

I suppose you think that SUN should have brought out another language in
addition to JAVA. Maybe they would have called it COCO - it would do the
same thing as JAVA but be syntactically different in most every way so
everyone would have to learn two languages.

T :)
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this
difference thing. Microsoft should have flipped a coin and just put all
of there resources on either one of them.


LOL! I guess you don't work in marketing... :-)

May 14 '06 #6
Marketing is correct; VB.NET exists almost entirely because of marketing.
Almost everything in the .NET Framework, including all of ASP.NET, is written
in C#. C# was designed by Anders Hejlsberg and his team as the original,
target language for the .NET Platform.
VB.NET had to come along for the ride because there are (were) 10 times more
VB Classic programmers than potential C# programmers, and MS could not simply
leave them in the lurch vis-a-vis .NET.

If VB.NET programmers would turn on Option Explicit and Option Strict, and
stay away from the Microsoft.VisualBasic namespace and all its "Classic VB
Crutch" methods and classes, and simply use the ones built into the Base
Class Library, then you'd have a chance of being correct in saying the two
languages are on a par with each other.

Pointer arithmetic and unsafe code, not.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
I am proud to say that I certainly don't work in Marketing (I passed
calculus).

I suppose you think that SUN should have brought out another language in
addition to JAVA. Maybe they would have called it COCO - it would do the
same thing as JAVA but be syntactically different in most every way so
everyone would have to learn two languages.

T :)
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this
difference thing. Microsoft should have flipped a coin and just put all
of there resources on either one of them.


LOL! I guess you don't work in marketing... :-)


May 14 '06 #7
Not to drag on this point but....

What are the "Classic VB Crutch Methods" that you refer to?
Thanks,
T

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:B2**********************************@microsof t.com...
Marketing is correct; VB.NET exists almost entirely because of marketing.
Almost everything in the .NET Framework, including all of ASP.NET, is
written
in C#. C# was designed by Anders Hejlsberg and his team as the original,
target language for the .NET Platform.
VB.NET had to come along for the ride because there are (were) 10 times
more
VB Classic programmers than potential C# programmers, and MS could not
simply
leave them in the lurch vis-a-vis .NET.

If VB.NET programmers would turn on Option Explicit and Option Strict, and
stay away from the Microsoft.VisualBasic namespace and all its "Classic VB
Crutch" methods and classes, and simply use the ones built into the Base
Class Library, then you'd have a chance of being correct in saying the two
languages are on a par with each other.

Pointer arithmetic and unsafe code, not.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
I am proud to say that I certainly don't work in Marketing (I passed
calculus).

I suppose you think that SUN should have brought out another language in
addition to JAVA. Maybe they would have called it COCO - it would do
the
same thing as JAVA but be syntactically different in most every way so
everyone would have to learn two languages.

T :)
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
> "Tina" <ti**********@nospammeexcite.com> wrote in message
> news:%2****************@TK2MSFTNGP05.phx.gbl...
>
>> IMHO, I have never seen two languages more on par with each other.
>> The
>> great mistake is that they both exist and therefore there is this
>> difference thing. Microsoft should have flipped a coin and just put
>> all
>> of there resources on either one of them.
>
> LOL! I guess you don't work in marketing... :-)
>


May 14 '06 #8

Tina wrote:
Not to drag on this point but....

What are the "Classic VB Crutch Methods" that you refer to?


He's referring to the Microsoft.VisualBasic namespace, and the stuff
therein. However, I would disagree with the 'crutch' characterization -
the VB namespace functions generally do things in a more 'Basic-like'
way.

For example, this namespace contains a Left function, for taking the
left n characters of a string - C#ers would do this with
String.Substring. However, Left includes additional sanity checks, as
shown by this Reflector output:

public static string Left(string str, int Length)
{
if (Length < 0)
{
throw new
ArgumentException(Utils.GetResourceString("Argumen t_GEZero1",
"Length"));
}
if ((Length == 0) || (str == null))
{
return "";
}
if (Length >= str.Length)
{
return str;
}
return str.Substring(0, Length);
}
Now, the C# 'attitude' would be to say that, for example, anyone who
asks for the left 6 characters of a 3 character string, or the left 4
characters of a null string variable, deserves everything they get. The
VB 'attitude' is that the former should get the string itself, and the
latter should get an empty string

Anycode using the Microsoft.VisiualBasic.Compatibility namespace, on
the other hand, should be rewritten asap.

--
Larry Lard
Replies to group please

May 15 '06 #9

Tina wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)
Hmm, a strongly typed dataset, or no?

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?


So it's not a strongyly-typed dataset. Which means you don't have
Option Strict On in VB. I strongly recommend you always have Option
String On (except in specialised cases where late binding is necessary,
eg Office Interop). Compile time errors are a hundred times better than
run time errors.

Of course, this will mean your VB will end up looking like C#:

theRow = CType(DsLogin1.CustLogin.Rows(0), CustLoginRow)

--
Larry Lard
Replies to group please

May 15 '06 #10
Yes, strongly typed data set. so?
(thanks for the answer on the "Crutch methods")
T
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...

Tina wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)


Hmm, a strongly typed dataset, or no?

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?


So it's not a strongyly-typed dataset. Which means you don't have
Option Strict On in VB. I strongly recommend you always have Option
String On (except in specialised cases where late binding is necessary,
eg Office Interop). Compile time errors are a hundred times better than
run time errors.

Of course, this will mean your VB will end up looking like C#:

theRow = CType(DsLogin1.CustLogin.Rows(0), CustLoginRow)

--
Larry Lard
Replies to group please

May 15 '06 #11

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

Similar topics

34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
21
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
21
by: Rich | last post by:
I was considering C# for developing a scientific application, but I have noticed a ~30% difference between VC++ .NET and C# on the same machine, under identical conditions: double a = 0,b = 0, c...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
12
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
9
by: viki1967 | last post by:
Hi all! This new forum its great! :) Congratulations !!! My answer: why this my code not working? Nothing error but not work the difference.... : <html>
11
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
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...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.