Solved

SqlDataReader Class constructor

Posted on 2013-02-04
4
247 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Setting runtime form location 4 29
Saveas need to save a copy 16 26
Help with LINQ and XML 10 26
Web Form VB.Net  import CSV 4 21
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now