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