473,412 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Connection string

Rob
Anyone know why the word "New" is required ?

Dim cn As OleDbConnection

cn = New OleDbConnection
Nov 23 '05 #1
3 895
"Rob" <rw*****@comcast.net> schrieb:
Anyone know why the word "New" is required ?

Dim cn As OleDbConnection

cn = New OleDbConnection


It's required to create a new instance of the class 'OleDbConnection'. Note
that 'New' is not required for value types like structures.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #2
Yes.

There is a big difference between an object and a reference to that object.

10 different variables can reference the same object. But there would be
only one object in memory.

This is quite different from having each variable point to a different
object, and there being 10 actual objects in memory.

So, with New, you specify you want to create an instance of an object. If
you don't need a new instance, because you are using that variable to point
to an existing one, then you wouldn't want to use the new operator to create
one.

"Rob" <rw*****@comcast.net> wrote in message
news:P-******************************@comcast.com...
Anyone know why the word "New" is required ?

Dim cn As OleDbConnection

cn = New OleDbConnection

Nov 23 '05 #3
Rob,

An other explanation.

You need memoryplaces in your program to hold whatever.

This can be a real value or a reference to something.

(whatever scope) a as whatever

This creates a fixed part of memory in a program(in a stack or whatever), it
knows what it is because you tell what it is. If it is a class than it is a
place to be able to set the reference address to the object.

a = new mywhateverclass tells that the refence is to a new object instanced
from that class.

VB Net has that nice command that does this in one time. In C# this does not
exist.

(whatever scope) a as new mywhateverclass.

I hope this helps,

Cor
Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: iKiLL | last post by:
Hi All Code Below for this problem ERROR: "An existing connection was forcibly closed by the remote host"
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
2
by: dbonin1599 | last post by:
I have the following code, the first set of code is the SQL version, the second set of code is an attempt to put the code into a VB String see "UpdateVariations". I need help, I think most of it is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.