// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_CONFIGURATION
+
using System;
using System.Collections;
using System.Configuration;
}
}
}
+
+#endif
\ No newline at end of file
using System.Configuration;
using System.Data;
using System.Data.Common;
+#if !NO_ODBC
using System.Data.Odbc;
+#endif
using System.Data.SqlClient;
using System.IO;
using System.Linq;
public class ConnectionManager
{
private static ConnectionManager instance;
- private ConnectionHolder<OdbcConnection> odbc;
private ConnectionHolder<SqlConnection> sql;
private const string OdbcEnvVar = "SYSTEM_DATA_ODBC";
if (sql != null)
CreateMssqlDatabase();
+#if !NO_ODBC
odbc = ConnectionHolder<OdbcConnection>.FromEnvVar(OdbcEnvVar);
if (odbc != null)
CreateMysqlDatabase();
+#endif
}
private void CreateMssqlDatabase()
}
}
+#if !NO_ODBC
private void CreateMysqlDatabase()
{
DBHelper.ExecuteNonQuery(odbc.Connection, $"CREATE DATABASE {DatabaseName}");
DBHelper.ExecuteNonQuery(odbc.Connection, subQuery);
}
}
+#endif
private void DropMssqlDatabase()
{
DBHelper.ExecuteNonQuery(sql.Connection, query);
}
+#if !NO_ODBC
private void DropMysqlDatabase()
{
string query = $"DROP DATABASE [{DatabaseName}]";
DBHelper.ExecuteNonQuery(odbc.Connection, query);
}
+#endif
// Split SQL script by "GO" statements
private static IEnumerable<string> SplitSqlStatements(string sqlScript)
public string DatabaseName { get; }
+#if !NO_ODBC
+
+ private ConnectionHolder<OdbcConnection> odbc;
+
public ConnectionHolder<OdbcConnection> Odbc
{
get
return odbc;
}
}
+#endif
public ConnectionHolder<SqlConnection> Sql
{
public void Close()
{
sql?.CloseConnection();
+#if !NO_ODBC
odbc?.CloseConnection();
+#endif
}
}
public static ConnectionHolder<TConnection> FromEnvVar(string envVarName)
{
+#if NO_CONFIGURATION
+ throw new NotImplementedException ();
+#else
string variable = Environment.GetEnvironmentVariable(envVarName) ?? string.Empty;
var envParts = variable.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
if (envParts.Length == 0 || string.IsNullOrEmpty(envParts[0]))
return new ConnectionHolder<TConnection>(connConfig.Engine, factory, connectionString);
}
throw new InvalidOperationException($"Connection {connectionName} not found");
+#endif
}
}
}
//
using System;
-using System.Configuration;
using System.Globalization;
using System.Xml;
string msg = string.Format (CultureInfo.InvariantCulture,
"Invalid value '{0}' for attribute {1}.",
value, name);
- throw new ConfigurationErrorsException (msg, cause, node);
+ throw new ArgumentOutOfRangeException (msg, cause);
}
static Exception CreateAttributeMissingException (string name, XmlNode node)
{
string msg = string.Format (CultureInfo.InvariantCulture,
"Missing '{0}' attribute.", name);
- throw new ConfigurationErrorsException (msg, node);
+ throw new ArgumentException (msg);
}
}
}
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_CONFIGURATION
+
using System;
using System.Collections;
using System.Configuration;
}
}
}
+
+#endif
\ No newline at end of file
using System;
using System.Data;
using System.Data.Common;
-using System.Data.Odbc;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Globalization;
namespace MonoTests.System.Data.Connected
{
[TestFixture]
- [Category ("odbc")]
[Category ("sqlserver")]
public class DataReaderTest
{
[Test]
public void GetSchemaTable_Command_Disposed ()
{
- if (RunningOnMono && (conn is OdbcConnection))
+ if (RunningOnMono)
Assert.Ignore ("Our statement handle is closed when we dispose the (Odbc)Command");
IDataReader reader = null;
using System;
using System.Data;
using System.Data.Common;
-using System.Data.Odbc;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Globalization;
namespace MonoTests.System.Data.Connected
{
[TestFixture]
- [Category ("odbc")]
[Category ("sqlserver")]
public class DbDataReaderTest
{
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Common;
// FIXME: Add test for ContinueUpdateOnError property
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Common;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Odbc;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Common;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Text;
using System.Data;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Common;
}
}
}
+
+#endif
\ No newline at end of file
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Common;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Odbc;
}
}
}
+
+#endif
\ No newline at end of file
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
+#if !NO_ODBC
using System;
using System.Collections;
using System.Data;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Odbc;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Data;
using System.Data.Odbc;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System.Data.Odbc;
using NUnit.Framework;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Text;
using System.Data;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using System;
using System.Text;
using System.Data;
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
//\r
\r
+#if !NO_ODBC\r
+\r
using NUnit.Framework;\r
using System;\r
using System.Data;\r
}\r
}\r
}\r
+\r
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_ODBC
+
using NUnit.Framework;
using System;
using System.Data;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_OLEDB
+
using System.Data;
using System.Data.OleDb;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_OLEDB
using System;
using System.Data;
using System.Data.OleDb;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_OLEDB
+
using System;
using System.Data;
+#if !NO_ODBC
using System.Data.Odbc;
+#endif
using System.Data.OleDb;
using NUnit.Framework;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_OLEDB
+
using System.Data.OleDb;
using NUnit.Framework;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NO_OLEDB
using NUnit.Framework;
using System;
using System.Data;
}
}
}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
//\r
\r
+#if !NO_OLEDB\r
using NUnit.Framework;\r
using System;\r
using System.Data;\r
}\r
}\r
}\r
+\r
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
//\r
\r
+#if !NO_OLEDB\r
+\r
using NUnit.Framework;\r
using System;\r
using System.Data;\r
}\r
}\r
}\r
+\r
+#endif
\ No newline at end of file