Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET Equivalent of C#

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
US
Is there a VB.NET equivalent (More of a work-around) to the C# using keyword in the ability to return execution to the original routine. I know that VB.NET does not have this ability, but wondering what is recommended for VB.NET.

For example if I want to return a DataReader and once I'm done looping through the reader, return execution back to the method which gave me the reader object:

Code:
public static OleDbDataReader LendReader(string sql)
{
  using (OleDbConnection conn = CreateConnection())
  {
    conn.Open()
    OleDbCommand c = new OleDbCommand(sql,conn);
    OleDbDataAdapter r = c.ExecuteReader();
    return r;
  }
}

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
The VB.NET "equivalent" is a Try Catch Finally block that disposes of the objects in Finally. There's nothing quite so clean as the "using" construct in VB.NET currently, though as I understand VS 2005 will have "Using" for the language.
 
Sounds like I need to add the reader to the method which lends itself out..

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top