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
40 public class DataTools
\r
46 static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType,
\r
47 ParameterDirection Direction)
\r
50 throw new System.ArgumentNullException ("Cmd");
\r
51 if (ParameterName == null)
\r
52 throw new System.ArgumentNullException ("ParameterName");
\r
54 IDataParameter param = Cmd.CreateParameter ();
\r
55 Cmd.Parameters.Add (param);
\r
56 param.ParameterName = ParameterName;
\r
57 param.Direction = Direction;
\r
58 param.DbType = DbType;
\r
62 static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType)
\r
65 throw new System.ArgumentNullException ("Cmd");
\r
66 if (ParameterName == null)
\r
67 throw new System.ArgumentNullException("ParameterName");
\r
69 IDataParameter param = Cmd.CreateParameter ();
\r
70 Cmd.Parameters.Add (param);
\r
71 param.ParameterName = ParameterName;
\r
72 param.DbType = DbType;
\r
76 static public DataSet FillDataSet (IDbConnection conn, string SelectCommand)
\r
79 throw new System.ArgumentNullException ("conn");
\r
80 if (SelectCommand == null)
\r
81 throw new System.ArgumentNullException ("SelectCommand");
\r
83 DataSet ds = new DataSet ();
\r
84 IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand);
\r
85 if (conn.State != ConnectionState.Open)
\r
91 static public DataSet FillDataSet(IDbCommand SelectCommand)
\r
93 if (SelectCommand == null)
\r
94 throw new System.ArgumentNullException ("SelectCommand");
\r
96 DataSet ds = new DataSet ();
\r
97 IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (SelectCommand);
\r
98 if (adapter.SelectCommand.Connection.State != ConnectionState.Open)
\r
99 adapter.SelectCommand.Connection.Open ();
\r
104 static public DataSet FillDataSet(string ConfigSetting, string SelectCommand)
\r
106 if (ConfigSetting == null)
\r
107 throw new System.ArgumentNullException ("ConfigSetting");
\r
108 if (SelectCommand == null)
\r
109 throw new System.ArgumentNullException ("SelectCommand");
\r
111 IDbConnection conn = ProviderFactory.CreateConnectionFromConfig (ConfigSetting);
\r
116 ds = new DataSet ();
\r
117 IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand);
\r