Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SqlDataReader Class constructor

Posted on 2013-02-04
4
255 Views
Last Modified: 2013-02-04
What is happening in the 3rd line of code here:
MyReader = command3.ExecuteReader(CommandBehavior.CloseConnection)
If MyReader.Read Then
     FromAddress = MyReader("Email")

Open in new window

It looks like it is calling a constructor of MyReader but I see nothing in the documentation like that.
0
Comment
Question by:allelopath
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 100 total points
ID: 38852125
It looks like a variable to me...
it gives me the same results as  FromAddress = MyReader.Item("Email")
0
 
LVL 1

Author Comment

by:allelopath
ID: 38852133
You're right, that's seems to be how it works, but I don't see anything in the documentation saying that MyReader("x") is the same as MyReader.Item("x").
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 38852148
If you try i(I've tried it) to write the command and open a "(" you will see the syntax...


John (Yiannis)
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 400 total points
ID: 38852170
It's not the constructor. In VB.NET there is the concept of a default property. Such a property allows you to treat the object as it were akin to an array, and you can, in effect, index the object to return some value. In this case, the default property of the SqlDataReader class is the Item property, which gives you access to the columns the SqlDataReader got from the database. In your example, you are simply assigning the value of the "Email" column to the FromAddress variable.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question