2 // Mono.Data.DataTools
\r
5 // Brian Ritchie (brianlritchie@hotmail.com)
\r
8 // Copyright (C) Brian Ritchie, 2002
\r
13 // Permission is hereby granted, free of charge, to any person obtaining
\r
14 // a copy of this software and associated documentation files (the
\r
15 // "Software"), to deal in the Software without restriction, including
\r
16 // without limitation the rights to use, copy, modify, merge, publish,
\r
17 // distribute, sublicense, and/or sell copies of the Software, and to
\r
18 // permit persons to whom the Software is furnished to do so, subject to
\r
19 // the following conditions:
\r
21 // The above copyright notice and this permission notice shall be
\r
22 // included in all copies or substantial portions of the Software.
\r
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
38 /// Summary description for ProviderTools.
\r
41 [Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")]
\r
43 public class DataTools
\r
49 static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType,
\r
50 ParameterDirection Direction)
\r
53 throw new System.ArgumentNullException ("Cmd");
\r
54 if (ParameterName == null)
\r
55 throw new System.ArgumentNullException ("ParameterName");
\r
57 IDataParameter param = Cmd.CreateParameter ();
\r
58 Cmd.Parameters.Add (param);
\r
59 param.ParameterName = ParameterName;
\r
60 param.Direction = Direction;
\r
61 param.DbType = DbType;
\r
65 static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType)
\r
68 throw new System.ArgumentNullException ("Cmd");
\r
69 if (ParameterName == null)
\r
70 throw new System.ArgumentNullException("ParameterName");
\r
72 IDataParameter param = Cmd.CreateParameter ();
\r
73 Cmd.Parameters.Add (param);
\r
74 param.ParameterName = ParameterName;
\r
75 param.DbType = DbType;
\r
79 static public DataSet FillDataSet (IDbConnection conn, string SelectCommand)
\r
82 throw new System.ArgumentNullException ("conn");
\r
83 if (SelectCommand == null)
\r
84 throw new System.ArgumentNullException ("SelectCommand");
\r
86 DataSet ds = new DataSet ();
\r
87 IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand);
\r
88 if (conn.State != ConnectionState.Open)
\r
94 static public DataSet FillDataSet(IDbCommand SelectCommand)
\r
96 if (SelectCommand == null)
\r
97 throw new System.ArgumentNullException ("SelectCommand");
\r
99 DataSet ds = new DataSet ();
\r
100 IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (SelectCommand);
\r
101 if (adapter.SelectCommand.Connection.State != ConnectionState.Open)
\r
102 adapter.SelectCommand.Connection.Open ();
\r
107 static public DataSet FillDataSet(string ConfigSetting, string SelectCommand)
\r
109 if (ConfigSetting == null)
\r
110 throw new System.ArgumentNullException ("ConfigSetting");
\r
111 if (SelectCommand == null)
\r
112 throw new System.ArgumentNullException ("SelectCommand");
\r
114 IDbConnection conn = ProviderFactory.CreateConnectionFromConfig (ConfigSetting);
\r
119 ds = new DataSet ();
\r
120 IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand);
\r