*** empty log message ***
[mono.git] / mcs / class / Mono.Data.TdsClient / Mono.Data.TdsClient / TdsConnection.cs
1 //
2 // Mono.Data.TdsClient.TdsConnection.cs
3 //
4 // Author:
5 //   Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) 2002 Tim Coleman
8 //
9
10 using Mono.Data.TdsClient.Internal;
11 using System;
12 using System.Collections;
13 using System.ComponentModel;
14 using System.Data;
15
16 namespace Mono.Data.TdsClient {
17         public class TdsConnection : Component, ICloneable, IDbConnection
18         {
19                 #region Fields
20
21                 internal TdsConnectionInternal connection;
22
23                 #endregion // Fields
24
25                 #region Constructors
26
27                 public TdsConnection (TdsServerType serverType)
28                         : this (serverType, 15, true, false, IsolationLevel.ReadCommitted)
29                 {
30                 }
31
32                 public TdsConnection (TdsServerType serverType, int connectionTimeout)
33                         : this (serverType, connectionTimeout, true, false, IsolationLevel.ReadCommitted)
34                 {
35                 }
36
37                 public TdsConnection (TdsServerType serverType, int connectionTimeout, bool autoCommit)
38                         : this (serverType, connectionTimeout, autoCommit, false, IsolationLevel.ReadCommitted)
39                 {
40                 }
41
42                 public TdsConnection (TdsServerType serverType, int connectionTimeout, bool autoCommit, bool readOnly, IsolationLevel isolationLevel)
43                 {
44                         connection = new TdsConnectionInternal (serverType, connectionTimeout, autoCommit, readOnly, isolationLevel);
45                 }
46                         
47                 #endregion // Constructors
48
49                 #region Properties
50
51                 public string ConnectionString {
52                         get { return connection.ConnectionString; }
53                         set { connection.ConnectionString = value; }
54                 }
55
56                 public string Database {
57                         get { return connection.Database; }
58                         set { connection.Database = value; }
59                 }
60
61                 public ConnectionState State {
62                         get { return connection.State; }
63                 }
64                 
65                 public int ConnectionTimeout {
66                         get { return connection.ConnectionTimeout; }
67                         set { connection.ConnectionTimeout = value; }
68                 }
69                 
70                 #endregion // Properties
71
72                 #region Methods
73
74                 public void ChangeDatabase (string databaseName)
75                 {
76                         connection.ChangeDatabase (databaseName);
77                 }
78
79                 public void Close ()
80                 {
81                         connection.Close ();
82                 }
83
84                 IDbCommand IDbConnection.CreateCommand ()
85                 {
86                         return ((IDbConnection) connection).CreateCommand ();
87                 }
88
89                 object ICloneable.Clone()
90                 {
91                         throw new NotImplementedException ();
92                 }
93
94                 IDbTransaction IDbConnection.BeginTransaction ()
95                 {
96                         return ((IDbConnection) connection).BeginTransaction ();
97                 }
98
99                 IDbTransaction IDbConnection.BeginTransaction (IsolationLevel il)
100                 {
101                         return ((IDbConnection) connection).BeginTransaction (il);
102                 }
103
104                 public void Open ()
105                 {
106                         connection.Open ();
107                 }
108
109                 #endregion // Methods
110         }
111 }