What is Connection Object in ADO.Net

What is Connection Object in ADO.Net

What is Connection Object in ADO.Net?

The Connection Object establishes a connection to a specific data source.

The important properties supported by the Connection Object are:
a) ConnectionString

The important methods supported by the Connection Object are:
a) Open()
b) Close()
c) BeginTransaction()

Thanks & Regards
Paritosh Mohapatra


Author: Sreedharan.R25 Mar 2012 Member Level: Bronze   Points : 0

thanks, you information is more valuable

Author: Ajesh Madhukar Dalvi13 Aug 2012 Member Level: Silver   Points : 4

A Connection object in ADO.NET is used to establish a connection between a program (the program may be a windows page, a web page, a windows service, a web service etc.) and the database. The connection is open just long enough to get or update data. By quickly opening, then closing a connection, the server resources are used as little as possible. See code below on how to open a connection between UI and database...

'Code below in VB.NET ...
Dim object Conn as Sql Client.Sql Connection
Dim strConn as String
'First, create a connection object
objectConn=New SqlClient.SqlConnection()

'Next, build the Connection String
strConn &="Data Source=(local
strConn &="Initial Catalog=Database Name;"
strConn &= "User ID=admin;"
strConn &= "Password=;"

'Note here that the connection string may also be passed as a parameter
'to the connection string object during instantiation

objectConn.Connection String = strConn
objectConn.Open() 'Open the Connection

'The connection is now open
'Write your vb.net code here for operations on the database

Catch Ex As Exception
Message Box.Show(Ex.Message)

Author: ketan Italiya24 Sep 2013 Member Level: Gold   Points : 3

The Connection object is the first component of ADO.NET that you should be looking at. A connection sets a link between a data source and ADO.NET. A Connection object sits between a data source and a DataAdapter (via Command). You need to define a data provider and a data source when you create a connection. With these two, you can also specify the user ID and password depending on the type of data source. Figure 3-3 shows the relationship between a connection, a data source, and a data adapter.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: