|Devart.Data.Universal Namespace : UniConnection Class|
Represents an open connection to a server.
For a list of all members of this type, see UniConnection members.
Public Class UniConnection Inherits DbConnectionBase
public class UniConnection : DbConnectionBase
A UniConnection object represents a unique connection to the server. Use it in conjunction with UniCommand, UniDataReader, UniDataAdapter or other components for convenient interoperation with database.
When you create an instance of UniConnection, all properties are set to their initial values. For a list of these values, see the _ctor constructor.
If the UniConnection goes out of scope, it is not closed. Therefore, you must explicitly close the connection by calling Close.
A single UniConnection can be used by many UniCommand objects on the assumption that all operations will be done consecutively. In other words, you can not execute a SQL statement while an asynchronous operation is in progress.
The following example creates a UniCommand and a UniConnection. The UniConnection is opened and set as the Connection property. The example then calls ExecuteNonQuery method, and closes the connection. To accomplish this, the ExecuteNonQuery is passed a connection string and a query string that is SQL INSERT statement.
public void InsertRow(string myConnectionString)
// If the connection string is empty, use default.
if(myConnectionString == "")
myConnectionString = "Provider=SQL Server;Data Source=SERVER;Initial Catalog=Northwind;User ID=sa";
UniConnection myConn = new UniConnection(myConnectionString);
string myInsertQuery = "INSERT INTO Test.Dept(DeptNo, DName) Values(50, 'DEVELOPMENT')";
UniCommand myCommand = new UniCommand(myInsertQuery);
myCommand.Connection = myConn;
Public Sub InsertRow(myConnectionString As String)
' If the connection string is empty, use default.
If myConnectionString = "" Then
myConnectionString = "Provider=SQL Server;Data Source=SERVER;Initial Catalog=Northwind;User ID=sa"
Dim myConn As New UniConnection(myConnectionString)
Dim myInsertQuery As String = "INSERT INTO Test.Dept(DeptNo, DName) Values(50, 'DEVELOPMENT')"
Dim myCommand As New UniCommand(myInsertQuery)
myCommand.Connection = myConn
© 2002 - 2013 Devart. All Rights Reserved.