Exemplo n.º 1
0
	public static bool ConnectToRuntimeDataBase (ref CommonDataBase.DataBase DataBaseInstance,
						String DataBaseName, String DataBaseFileName, String ConnectionStringTemplate,
						String [] TablesCreationCommands,
						CommonDataBase.StatusCallBack StatusCallBackHandler)
		{
		if (!File.Exists (DataBaseFileName))
			{
			DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, "Master"));
			DataBaseInstance.SetMessageCallback (StatusCallBackHandler);
			CreateRuntimeDataBase (ref DataBaseInstance, DataBaseName, DataBaseFileName,
										StatusCallBackHandler);
			DataBaseInstance.Close ();
			if (DataBaseFileName.IndexOf (".db", StringComparison.OrdinalIgnoreCase) == -1)
				DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, DataBaseName));
			else
				DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, DataBaseFileName));
			DataBaseInstance.SetMessageCallback (StatusCallBackHandler);
			CreateRuntimeTables (ref DataBaseInstance, DataBaseName, TablesCreationCommands,
										StatusCallBackHandler);
			DataBaseInstance.Close ();
			}
		else
			{
			DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, "Master"));
			DataBaseInstance.SetMessageCallback (StatusCallBackHandler);
			AttachDataBase (DataBaseInstance, DataBaseName, DataBaseFileName);
			DataBaseInstance.Close ();
			if (DataBaseFileName.IndexOf (".db", StringComparison.OrdinalIgnoreCase) == -1)
				DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, DataBaseName));
			else
				DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, DataBaseFileName));
			DataBaseInstance.SetMessageCallback (StatusCallBackHandler);
			}

		return true;
		}
Exemplo n.º 2
0
		public static bool RemoveDataBase (ref CommonDataBase.DataBase DataBaseInstance,
						String DataBaseName, String DataBaseFileName, String ConnectionStringTemplate,
						CommonDataBase.StatusCallBack StatusCallBackHandler)
			{
			DataBaseInstance = new DataBase (String.Format (ConnectionStringTemplate, "Master"));
			DataBaseInstance.SetMessageCallback (StatusCallBackHandler);
			bool Return = DeleteRuntimeDataBase (ref DataBaseInstance, DataBaseName, DataBaseFileName,
										StatusCallBackHandler);
			DataBaseInstance.Close ();
			return Return;
			}