1 // ByteFX.Data data access components for .Net
\r
2 // Copyright (C) 2002-2003 ByteFX, Inc.
\r
4 // This library is free software; you can redistribute it and/or
\r
5 // modify it under the terms of the GNU Lesser General Public
\r
6 // License as published by the Free Software Foundation; either
\r
7 // version 2.1 of the License, or (at your option) any later version.
\r
9 // This library is distributed in the hope that it will be useful,
\r
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
12 // Lesser General Public License for more details.
\r
14 // You should have received a copy of the GNU Lesser General Public
\r
15 // License along with this library; if not, write to the Free Software
\r
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
19 using System.ComponentModel;
\r
20 using System.Collections.Specialized;
\r
23 namespace ByteFX.Data.Common
\r
26 /// Summary description for Connection.
\r
28 [ToolboxItem(false)]
\r
29 [System.ComponentModel.DesignerCategory("Code")]
\r
30 public class Connection : Component
\r
32 internal ConnectionString connString;
\r
33 internal ConnectionState state;
\r
34 internal IDataReader reader = null;
\r
37 public Connection(System.ComponentModel.IContainer container)
\r
40 /// Required for Windows.Forms Class Composition Designer support
\r
42 container.Add(this);
\r
51 protected void Init()
\r
53 state = ConnectionState.Closed;
\r
58 public string DataSource
\r
62 String s = connString["data source"];
\r
63 if (s == null || s.Length == 0)
\r
74 string s = connString["user id"];
\r
82 public string Password
\r
86 string pwd = connString["password"];
\r
94 public int ConnectionTimeout
\r
98 // Returns the connection time-out value set in the connection
\r
99 // string. Zero indicates an indefinite time-out period.
\r
100 if (connString == null)
\r
102 return connString.GetIntOption("connection timeout", 30);
\r
107 public string Database
\r
111 // Returns an initial database as set in the connection string.
\r
112 // An empty string indicates not set - do not return a null reference.
\r
113 return connString["database"];
\r
118 public ConnectionState State
\r
120 get { return state; }
\r
123 internal IDataReader Reader
\r
125 get { return reader; }
\r
126 set { reader = value; }
\r