Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I found this article on MySQL written by Mike Hillyer;

http://dev.mysql.com/tech-resources/articles/vb-blob-handling.html

 

Under the topic "Connection Object" Mike states:

Connection Object

 

Now that we have a connection string, we can connect to the database, first I will give a sample of how I connect.

 

Dim conn As ADODB.Connection

Set conn = New ADODB.Connection

conn.ConnectionString = GloConnectionString

conn.CursorLocation = adUseClient

conn.Open

 

In the first line we create an ADODB connection object in memory and in the second line we instanciate it. The alternative syntax to this is to type Dim conn As New ADODB.Connection

 

While I previously recommended the 'as New' syntax, I have since learned that it slows down your code since it must check if the object is instanciated every time a reference is made to the object.

 

This article is discussing VB6; I interperet this to mean ALL objects instanciated in the declaration will feel this performance hit.

 

But I'm curious, does anyone know if this has been fixed in VB.Net, and if so, is it all versions or only after certain years, such as fixed in 2003 but not 2002?

Edited by alreadyused
Posted

Yes, thankfully this is fixed in VB.NET

Really dumb design in the first place, but then again that "performance hit" is pretty inconsequential.

 

The lines:

Dim o As New c
Dim o As c = New c

are the same.

"Who is John Galt?"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...