Solved

SqlDataReader Class constructor

Posted on 2013-02-04
4
244 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
Comment Utility
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
Comment Utility
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
Comment Utility
If you try i(I've tried it) to write the command and open a "(" you will see the syntax...


John (Yiannis)
0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 400 total points
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

9 Experts available now in Live!

Get 1:1 Help Now