static SqliteDataAdapter PrepareDataAdapter()
		{
			SqliteCommand select  = new SqliteCommand("SELECT t, f, i, b FROM t1",_conn);
			SqliteCommand update = new SqliteCommand("UPDATE t1 SET t = :textP, f = :floatP, i = :integerP, n=:blobP WHERE t = :textP ");
			update.Connection=_conn;
			SqliteCommand delete = new SqliteCommand("DELETE FROM t1 WHERE t = :textP");
			delete.Connection=_conn;
			SqliteCommand insert = new SqliteCommand("INSERT INTO t1  (t, f, i, b ) VALUES(:textP,:floatP,:integerP,:blobP)");
			insert.Connection=_conn;
			SqliteDataAdapter custDA = new SqliteDataAdapter(select);
		
			SqliteParameter textP = new SqliteParameter();
			textP.ParameterName = "textP";
			textP.SourceColumn = "t";
		
			SqliteParameter floatP = new SqliteParameter();
			floatP.ParameterName = "floatP";
			floatP.SourceColumn = "f";
		
			SqliteParameter integerP = new SqliteParameter();
			integerP.ParameterName ="integerP";
			integerP.SourceColumn = "i";

			SqliteParameter blobP = new SqliteParameter();
			blobP.ParameterName = "blobP";
			blobP.SourceColumn = "b";
		
			update.Parameters.Add(textP);
			update.Parameters.Add(floatP);
			update.Parameters.Add(integerP);
			update.Parameters.Add(blobP);
		
			delete.Parameters.Add(textP);
		
			insert.Parameters.Add(textP);
			insert.Parameters.Add(floatP);
			insert.Parameters.Add(integerP);
			insert.Parameters.Add(blobP);
		
			custDA.UpdateCommand = update;
			custDA.DeleteCommand = delete;
			custDA.InsertCommand = insert;
		
			return custDA;
		}
Exemplo n.º 2
0
        /// <summary>
        /// <list type="bullet">
        /// <item>Initialises Inventory interface</item>
        /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
        /// <item>use default URI if connect string string is empty.</item>
        /// </list>
        /// </summary>
        /// <param name="dbconnect">connect string</param>
        public void Initialise(string dbconnect)
        {
            if (dbconnect == string.Empty)
            {
                dbconnect = "URI=file:inventoryStore.db,version=3";
            }
            m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect);
            conn = new SqliteConnection(dbconnect);

            conn.Open();

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(conn, assem, "InventoryStore");
            m.Update();

            SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn);
            invItemsDa = new SqliteDataAdapter(itemsSelectCmd);
            //            SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);

            SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn);
            invFoldersDa = new SqliteDataAdapter(foldersSelectCmd);

            ds = new DataSet();

            ds.Tables.Add(createInventoryFoldersTable());
            invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
            setupFoldersCommands(invFoldersDa, conn);
            m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");

            ds.Tables.Add(createInventoryItemsTable());
            invItemsDa.Fill(ds.Tables["inventoryitems"]);
            setupItemsCommands(invItemsDa, conn);
            m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");

            ds.AcceptChanges();
        }
 private DataTable ExecuteDataTable(string sql)
 {
     using (SqliteConnection conn = new SqliteConnection(connectionString))
     {
         sql = sql + " --dataProfilerIgnore";
         SqliteCommand cmd = new SqliteCommand(sql, conn);
         cmd.CommandTimeout = 1200;
         conn.Open();
         SqliteDataAdapter da = new SqliteDataAdapter(cmd);
         DataSet ds = new DataSet();
         da.Fill(ds);
         return ds.Tables[0];
     }
 }
Exemplo n.º 4
0
		static void Test(bool v3, string encoding) {
			if (!v3)
				Console.WriteLine("Testing Version 2" + (encoding != null ? " with " + encoding + " encoding" : ""));
			else
				Console.WriteLine("Testing Version 3");
				
			System.IO.File.Delete("SqliteTest.db");
		
			SqliteConnection dbcon = new SqliteConnection();
			
			// the connection string is a URL that points
			// to a file.  If the file does not exist, a 
			// file is created.

			// "URI=file:some/path"
			string connectionString =
				"URI=file:SqliteTest.db";
			if (v3)
				connectionString += ",Version=3";
			if (encoding != null)
				connectionString += ",encoding=" + encoding;
			dbcon.ConnectionString = connectionString;
				
			dbcon.Open();

			SqliteCommand dbcmd = new SqliteCommand();
			dbcmd.Connection = dbcon;
			
			dbcmd.CommandText = 
				"CREATE TABLE MONO_TEST ( " +
				"NID INT, " +
				"NDESC TEXT, " +
				"NTIME DATETIME); " +
				"INSERT INTO MONO_TEST  " +
				"(NID, NDESC, NTIME) " +
				"VALUES(1,'One (unicode test: \u05D0)', '2006-01-01')";
			Console.WriteLine("Create & insert modified rows = 1: " + dbcmd.ExecuteNonQuery());

			dbcmd.CommandText =
				"INSERT INTO MONO_TEST  " +
				"(NID, NDESC, NTIME) " +
				"VALUES(:NID,:NDESC,:NTIME)";
			dbcmd.Parameters.Add( new SqliteParameter("NID", 2) );
			dbcmd.Parameters.Add( new SqliteParameter(":NDESC", "Two (unicode test: \u05D1)") );
			dbcmd.Parameters.Add( new SqliteParameter(":NTIME", DateTime.Now) );
			Console.WriteLine("Insert modified rows with parameters = 1, 2: " + dbcmd.ExecuteNonQuery() + " , " + dbcmd.LastInsertRowID());

			dbcmd.CommandText =
				"INSERT INTO MONO_TEST  " +
				"(NID, NDESC, NTIME) " +
				"VALUES(3,'Three, quoted parameter test, and next is null; :NTIME', NULL)";
			Console.WriteLine("Insert with null modified rows and ID = 1, 3: " + dbcmd.ExecuteNonQuery() + " , " + dbcmd.LastInsertRowID());

			dbcmd.CommandText =
				"INSERT INTO MONO_TEST  " +
				"(NID, NDESC, NTIME) " +
				"VALUES(4,'Four with ANSI char: ü', NULL)";
			Console.WriteLine("Insert with ANSI char ü = 1, 4: " + dbcmd.ExecuteNonQuery() + " , " + dbcmd.LastInsertRowID());

			dbcmd.CommandText =
				"INSERT INTO MONO_TEST  " +
				"(NID, NDESC, NTIME) " +
				"VALUES(?,?,?)";
			dbcmd.Parameters.Clear();
			IDbDataParameter param1 = dbcmd.CreateParameter();
			param1.DbType = DbType.DateTime;
			param1.Value = 5;
			dbcmd.Parameters.Add(param1);			
			IDbDataParameter param2 = dbcmd.CreateParameter();
			param2.Value = "Using unnamed parameters";
			dbcmd.Parameters.Add(param2);
			IDbDataParameter param3 = dbcmd.CreateParameter();
			param3.DbType = DbType.DateTime;
			param3.Value = DateTime.Parse("2006-05-11 11:45:00");
			dbcmd.Parameters.Add(param3);
			Console.WriteLine("Insert with unnamed parameters = 1, 5: " + dbcmd.ExecuteNonQuery() + " , " + dbcmd.LastInsertRowID());

			dbcmd.CommandText =
				"SELECT * FROM MONO_TEST";
			SqliteDataReader reader;
			reader = dbcmd.ExecuteReader();

			Console.WriteLine("read and display data...");
			while(reader.Read())
				for (int i = 0; i < reader.FieldCount; i++)
					Console.WriteLine(" Col {0}: {1} (type: {2}, data type: {3})",
						i, reader[i] == null ? "(null)" : reader[i].ToString(), reader[i] == null ? "(null)" : reader[i].GetType().FullName, reader.GetDataTypeName(i));

			dbcmd.CommandText = "SELECT NDESC FROM MONO_TEST WHERE NID=2";
			Console.WriteLine("read and display a scalar = 'Two': " + dbcmd.ExecuteScalar());

			dbcmd.CommandText = "SELECT count(*) FROM MONO_TEST";
			Console.WriteLine("read and display a non-column scalar = 3: " + dbcmd.ExecuteScalar());

			Console.WriteLine("read and display data using DataAdapter/DataSet...");
			SqliteDataAdapter adapter = new SqliteDataAdapter("SELECT * FROM MONO_TEST", connectionString);
			DataSet dataset = new DataSet();
			adapter.Fill(dataset);
			foreach(DataTable myTable in dataset.Tables){
				foreach(DataRow myRow in myTable.Rows){
					foreach (DataColumn myColumn in myTable.Columns){
						Console.WriteLine(" " + myRow[myColumn]);
					}
				}
			}

			/*Console.WriteLine("read and display data using DataAdapter/DataTable...");
			DataTable dt = new DataTable();
			adapter.Fill(dt);
			DataView dv = new DataView(dt);
			foreach (DataRowView myRow in dv) {
				foreach (DataColumn myColumn in myRow.Row.Table.Columns) {
					Console.WriteLine(" " + myRow[myColumn.ColumnName]);
				}
			}*/
       		       		            
			try {
				dbcmd.CommandText = "SELECT NDESC INVALID SYNTAX FROM MONO_TEST WHERE NID=2";
				dbcmd.ExecuteNonQuery();
				Console.WriteLine("Should not reach here.");
			} catch (Exception e) {
				Console.WriteLine("Testing a syntax error: " + e.GetType().Name + ": " + e.Message);
			}

			/*try {
				dbcmd.CommandText = "SELECT 0/0 FROM MONO_TEST WHERE NID=2";
				Console.WriteLine("Should not reach here: " + dbcmd.ExecuteScalar());
			} catch (Exception e) {
				Console.WriteLine("Testing an execution error: " + e.GetType().Name + ": " + e.Message);
			}*/

			dataset.Dispose();
			adapter.Dispose();
			reader.Close();
			dbcmd.Dispose();
			dbcon.Close();
		}
Exemplo n.º 5
0
        //----------------------------------------------------------------------------------------------------
        /// <summary>
        /// 테이블 읽기
        /// </summary>
        /// <param name="table">테이블 객체</param>
        /// <param name="sql">SQL문</param>
        /// <returns>데이터어답터 객체</returns>
        //----------------------------------------------------------------------------------------------------
        public DbDataAdapter ReadTable( DataTable table, string sql )
        {
            if( !Connect() ) return null;

            DbDataAdapter adapter=null;

            try
            {
                // Select 커멘더 생성
                m_command = m_connection.CreateCommand();
                m_command.CommandType = CommandType.Text;
                m_command.CommandText = sql;

                // 어답터 생성
                switch(m_type)
                {
                case eType.SQLite:	adapter = new SqliteDataAdapter((SqliteCommand)m_command);	break;
                case eType.MySQL:	adapter = new MySqlDataAdapter((MySqlCommand)m_command);	break;
                case eType.MSSQL:	adapter = new SqlDataAdapter((SqlCommand)m_command);		break;
                case eType.Oracle:	adapter = new OracleDataAdapter((OracleCommand)m_command);	break;
                }

                // Insert,Update,Delete 컴멘더 생성
                DbCommandBuilder builder = null;
                switch(m_type)
                {
                case eType.SQLite:	builder = new SqliteCommandBuilder();	break;
                case eType.MySQL:	builder = new MySqlCommandBuilder();	break;
                case eType.MSSQL:	builder = new SqlCommandBuilder();		break;
                case eType.Oracle:	builder = new OracleCommandBuilder();	break;
                }
                builder.DataAdapter = adapter;
                adapter.InsertCommand = builder.GetInsertCommand();
                adapter.UpdateCommand = builder.GetUpdateCommand();
                adapter.DeleteCommand = builder.GetDeleteCommand();

                // 테이블 채워 넣기
                adapter.Fill(table);
                return adapter;
            }
            catch( Exception ex )
            {
                Log( ex.ToString() );
                m_error = ex.Message;
                CloseQuery();
                return null;
            }
        }
Exemplo n.º 6
0
        //----------------------------------------------------------------------------------------------------
        /// <summary>
        /// 아답터 생성
        /// </summary>
        /// <param name="table_name">테이블 이름</param>
        /// <returns>데이터어답터 객체</returns>
        //----------------------------------------------------------------------------------------------------
        public DbDataAdapter CreateAdapter( string table_name )
        {
            if( !Connect() ) return null;

            // Select 커멘더 생성
            DbCommand command = m_connection.CreateCommand();
            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM " + table_name;

            // 어답터 생성
            DbDataAdapter adapter=null;
            switch(m_type)
            {
            case eType.SQLite:	adapter = new SqliteDataAdapter((SqliteCommand)command);	break;
            case eType.MySQL:	adapter = new MySqlDataAdapter((MySqlCommand)command);		break;
            case eType.MSSQL:	adapter = new SqlDataAdapter((SqlCommand)command);			break;
            case eType.Oracle:	adapter = new OracleDataAdapter((OracleCommand)command);	break;
            }

            // Insert,Update,Delete 컴멘더 생성
            DbCommandBuilder builder = null;
            switch(m_type)
            {
            case eType.SQLite:	builder = new SqliteCommandBuilder();	break;
            case eType.MySQL:	builder = new MySqlCommandBuilder();	break;
            case eType.MSSQL:	builder = new SqlCommandBuilder();		break;
            case eType.Oracle:	builder = new OracleCommandBuilder();	break;
            }
            builder.DataAdapter = adapter;
            adapter.InsertCommand = builder.GetInsertCommand();
            adapter.UpdateCommand = builder.GetUpdateCommand();
            adapter.DeleteCommand = builder.GetDeleteCommand();
            return adapter;
        }
Exemplo n.º 7
0
 public override void Dispose ()
 {
     if (g_conn != null)
     {
         g_conn.Close();
         g_conn = null;
     }
     if (ds != null)
     {
         ds.Dispose();
         ds = null;
     }
     if (da != null)
     {
         da.Dispose();
         da = null;
     }
     if (daf != null)
     {
         daf.Dispose();
         daf = null;
     }
     if (dua != null)
     {
         dua.Dispose();
         dua = null;
     }
     if (daa != null)
     {
         daa.Dispose();
         daa = null;
     }
 }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="daf"></param>
        /// <param name="conn"></param>
        private void setupUserFriendsCommands(SqliteDataAdapter daf, SqliteConnection conn)
        {
            daf.InsertCommand = SQLiteUtil.createInsertCommand("userfriends", ds.Tables["userfriends"]);
            daf.InsertCommand.Connection = conn;

            daf.UpdateCommand = SQLiteUtil.createUpdateCommand("userfriends", "ownerID=:ownerID and friendID=:friendID", ds.Tables["userfriends"]);
            daf.UpdateCommand.Connection = conn;

            SqliteCommand delete = new SqliteCommand("delete from userfriends where ownerID=:ownerID and friendID=:friendID");
            delete.Parameters.Add(SQLiteUtil.createSqliteParameter("ownerID", typeof(String)));
            delete.Parameters.Add(SQLiteUtil.createSqliteParameter("friendID", typeof(String)));
            delete.Connection = conn;
            daf.DeleteCommand = delete;

        }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="da"></param>
 /// <param name="conn"></param>
 private void setupLandAccessCommands(SqliteDataAdapter da, SqliteConnection conn)
 {
     da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]);
     da.InsertCommand.Connection = conn;
 }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="da"></param>
        /// <param name="conn"></param>
        private void setupLandCommands(SqliteDataAdapter da, SqliteConnection conn)
        {
            da.InsertCommand = createInsertCommand("land", ds.Tables["land"]);
            da.InsertCommand.Connection = conn;

            da.UpdateCommand = createUpdateCommand("land", "UUID=:UUID", ds.Tables["land"]);
            da.UpdateCommand.Connection = conn;
        }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="da"></param>
 /// <param name="conn"></param>
 private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn)
 {
     da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]);
     da.InsertCommand.Connection = conn;
 }
Exemplo n.º 12
0
 public void Dispose()
 {
     if (m_conn != null)
     {
         m_conn.Close();
         m_conn = null;
     }
     if (ds != null)
     {
         ds.Dispose();
         ds = null;
     }
     if (primDa != null)
     {
         primDa.Dispose();
         primDa = null;
     }
     if (shapeDa != null)
     {
         shapeDa.Dispose();
         shapeDa = null;
     }
     if (itemsDa != null)
     {
         itemsDa.Dispose();
         itemsDa = null;
     }
     if (terrainDa != null)
     {
         terrainDa.Dispose();
         terrainDa = null;
     }
     if (landDa != null)
     {
         landDa.Dispose();
         landDa = null;
     }
     if (landAccessListDa != null)
     {
         landAccessListDa.Dispose();
         landAccessListDa = null;
     }
     if (regionSettingsDa != null)
     {
         regionSettingsDa.Dispose();
         regionSettingsDa = null;
     }
 }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="da"></param>
        /// <param name="conn"></param>
        private void setupLandAccessCommands(SqliteDataAdapter da, SqliteConnection conn)
        {
            da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]);
            da.InsertCommand.Connection = conn;

            da.UpdateCommand = createUpdateCommand("landaccesslist", "LandUUID=:landUUID", "AccessUUID=:AccessUUID", ds.Tables["landaccesslist"]);
            da.UpdateCommand.Connection = conn;

            SqliteCommand delete = new SqliteCommand("delete from landaccesslist where LandUUID= :LandUUID and AccessUUID= :AccessUUID");
            delete.Parameters.Add(createSqliteParameter("LandUUID", typeof(String)));
            delete.Parameters.Add(createSqliteParameter("AccessUUID", typeof(String)));
            da.DeleteCommand = delete;
            da.DeleteCommand.Connection = conn;
            
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="da"></param>
        /// <param name="conn"></param>
        private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn)
        {
            lock (ds)
            {
                da.InsertCommand = createInsertCommand("inventoryfolders", ds.Tables["inventoryfolders"]);
                da.InsertCommand.Connection = conn;

                da.UpdateCommand = createUpdateCommand("inventoryfolders", "UUID=:UUID", ds.Tables["inventoryfolders"]);
                da.UpdateCommand.Connection = conn;

                SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID");
                delete.Parameters.Add(createSqliteParameter("UUID", typeof(String)));
                delete.Connection = conn;
                da.DeleteCommand = delete;
            }
        }
 /// <summary>
 /// Closes the inventory interface
 /// </summary>
 public void Dispose()
 {
     if (conn != null)
     {
         conn.Close();
         conn = null;
     }
     if (invItemsDa != null)
     {
         invItemsDa.Dispose();
         invItemsDa = null;
     }
     if (invFoldersDa != null)
     {
         invFoldersDa.Dispose();
         invFoldersDa = null;
     }
     if (ds != null)
     {
         ds.Dispose();
         ds = null;
     }
 }
Exemplo n.º 16
0
		static void Main(string[] args)
		{
			Console.WriteLine("If this test works, you should get:");
			Console.WriteLine("Data 1: 5");
			Console.WriteLine("Data 2: Mono");

			Console.WriteLine("create SqliteConnection...");
			SqliteConnection dbcon = new SqliteConnection();
			
			// the connection string is a URL that points
			// to a file.  If the file does not exist, a 
			// file is created.

			// "URI=file:some/path"
			string connectionString =
				"URI=file:SqliteTest.db";
			Console.WriteLine("setting ConnectionString using: " + 
				connectionString);
			dbcon.ConnectionString = connectionString;
				
			Console.WriteLine("open the connection...");
			dbcon.Open();

			Console.WriteLine("create SqliteCommand to CREATE TABLE MONO_TEST");
			SqliteCommand dbcmd = new SqliteCommand();
			dbcmd.Connection = dbcon;
			
			dbcmd.CommandText = 
				"CREATE TABLE MONO_TEST ( " +
				"NID INT, " +
				"NDESC TEXT )";
			Console.WriteLine("execute command...");
			dbcmd.ExecuteNonQuery();

			Console.WriteLine("set and execute command to INSERT INTO MONO_TEST");
			dbcmd.CommandText =
				"INSERT INTO MONO_TEST  " +
				"(NID, NDESC )"+
				"VALUES(5,'Mono')";
			dbcmd.ExecuteNonQuery();

			Console.WriteLine("set command to SELECT FROM MONO_TEST");
			dbcmd.CommandText =
				"SELECT * FROM MONO_TEST";
			SqliteDataReader reader;
			Console.WriteLine("execute reader...");
			reader = dbcmd.ExecuteReader();

			Console.WriteLine("read and display data...");
			while(reader.Read()) {
				Console.WriteLine("Data 1: " + reader[0].ToString());
				Console.WriteLine("Data 2: " + reader[1].ToString());
			}

			Console.WriteLine("read and display data using DataAdapter...");
			SqliteDataAdapter adapter = new SqliteDataAdapter("SELECT * FROM MONO_TEST", connectionString);
			DataSet dataset = new DataSet();
			adapter.Fill(dataset);
			foreach(DataTable myTable in dataset.Tables){
				foreach(DataRow myRow in myTable.Rows){
					foreach (DataColumn myColumn in myTable.Columns){
						Console.WriteLine(myRow[myColumn]);
					}
				}
			}

			
			Console.WriteLine("clean up...");
			dataset.Dispose();
			adapter.Dispose();
			reader.Close();
			dbcmd.Dispose();
			dbcon.Close();

			Console.WriteLine("Done.");
		}
Exemplo n.º 17
0
        private void setupAgentCommands(SqliteDataAdapter da, SqliteConnection conn)
        {
            da.InsertCommand = SQLiteUtil.createInsertCommand("useragents", ds.Tables["useragents"]);
            da.InsertCommand.Connection = conn;

            da.UpdateCommand = SQLiteUtil.createUpdateCommand("useragents", "UUID=:UUID", ds.Tables["useragents"]);
            da.UpdateCommand.Connection = conn;

            SqliteCommand delete = new SqliteCommand("delete from useragents where UUID = :ProfileID");
            delete.Parameters.Add(SQLiteUtil.createSqliteParameter("ProfileID", typeof(String)));
            delete.Connection = conn;
            da.DeleteCommand = delete;
        }
Exemplo n.º 18
0
 private void setupRegionSettingsCommands(SqliteDataAdapter da, SqliteConnection conn)
 {
     da.InsertCommand = createInsertCommand("regionsettings", ds.Tables["regionsettings"]);
     da.InsertCommand.Connection = conn;
     da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID=:regionUUID", ds.Tables["regionsettings"]);
     da.UpdateCommand.Connection = conn;
 }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="daf"></param>
        /// <param name="conn"></param>
        private void setupAvatarAppearanceCommands(SqliteDataAdapter daa, SqliteConnection conn)
        {
            daa.InsertCommand = SQLiteUtil.createInsertCommand("avatarappearance", ds.Tables["avatarappearance"]);
            daa.InsertCommand.Connection = conn;

            daa.UpdateCommand = SQLiteUtil.createUpdateCommand("avatarappearance", "Owner=:Owner", ds.Tables["avatarappearance"]);
            daa.UpdateCommand.Connection = conn;

            SqliteCommand delete = new SqliteCommand("delete from avatarappearance where Owner=:Owner");
            delete.Parameters.Add(SQLiteUtil.createSqliteParameter("Owner", typeof(String)));
            delete.Connection = conn;
            daa.DeleteCommand = delete;
        }
Exemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="da"></param>
        /// <param name="conn"></param>
        private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn)
        {
            da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]);
            da.InsertCommand.Connection = conn;

            da.UpdateCommand = createUpdateCommand("primshapes", "UUID=:UUID", ds.Tables["primshapes"]);
            da.UpdateCommand.Connection = conn;

            SqliteCommand delete = new SqliteCommand("delete from primshapes where UUID = :UUID");
            delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
            delete.Connection = conn;
            da.DeleteCommand = delete;
        }
Exemplo n.º 21
0
        /// <summary>
        /// <list type="bullet">
        /// <item>Initialises User Interface</item>
        /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
        /// <item>use default URI if connect string string is empty.</item>
        /// </list>
        /// </summary>
        /// <param name="connect">connect string</param>
        override public void Initialise(string connect)
        {
            // default to something sensible
            if (connect == "")
                connect = "URI=file:userprofiles.db,version=3";

            SqliteConnection conn = new SqliteConnection(connect);

            // This sucks, but It doesn't seem to work with the dataset Syncing :P
            g_conn = conn;
            g_conn.Open();

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(g_conn, assem, "UserStore");
            m.Update();


            ds = new DataSet();
            da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn));
            dua = new SqliteDataAdapter(new SqliteCommand(userAgentSelect, conn));
            daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn));
            daa = new SqliteDataAdapter(new SqliteCommand(AvatarAppearanceSelect, conn));
            //if (daa == null) m_log.Info("[SQLiteUserData]: daa = null");

            lock (ds)
            {
                ds.Tables.Add(createUsersTable());
                ds.Tables.Add(createUserAgentsTable());
                ds.Tables.Add(createUserFriendsTable());
                ds.Tables.Add(createAvatarAppearanceTable());

                setupUserCommands(da, conn);
                da.Fill(ds.Tables["users"]);

                setupAgentCommands(dua, conn);
                dua.Fill(ds.Tables["useragents"]);

                setupUserFriendsCommands(daf, conn);
                daf.Fill(ds.Tables["userfriends"]);

                setupAvatarAppearanceCommands(daa, conn);
                daa.Fill(ds.Tables["avatarappearance"]);
            }

            return;
        }
Exemplo n.º 22
0
        // Temporary attribute while this is experimental

        /***********************************************************************
         *
         *  Public Interface Functions
         *
         **********************************************************************/

        /// <summary>
        /// See IRegionDataStore
        /// <list type="bullet">
        /// <item>Initialises RegionData Interface</item>
        /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
        /// </list>
        /// </summary>
        /// <param name="connectionString">the connection string</param>
        public void Initialise(string connectionString)
        {
            m_connectionString = connectionString;

            ds = new DataSet();

            m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString);
            m_conn = new SqliteConnection(m_connectionString);
            m_conn.Open();



            SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn);
            primDa = new SqliteDataAdapter(primSelectCmd);
            //            SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);

            SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn);
            shapeDa = new SqliteDataAdapter(shapeSelectCmd);
            // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa);

            SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn);
            itemsDa = new SqliteDataAdapter(itemsSelectCmd);

            SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn);
            terrainDa = new SqliteDataAdapter(terrainSelectCmd);

            SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn);
            landDa = new SqliteDataAdapter(landSelectCmd);

            SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn);
            landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd);

            SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn);
            regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd);
            // This actually does the roll forward assembly stuff
            Assembly assem = GetType().Assembly;
            Migration m = new Migration(m_conn, assem, "RegionStore");
            m.Update();

            lock (ds)
            {
                ds.Tables.Add(createPrimTable());
                setupPrimCommands(primDa, m_conn);
                primDa.Fill(ds.Tables["prims"]);

                ds.Tables.Add(createShapeTable());
                setupShapeCommands(shapeDa, m_conn);

                ds.Tables.Add(createItemsTable());
                setupItemsCommands(itemsDa, m_conn);
                itemsDa.Fill(ds.Tables["primitems"]);

                ds.Tables.Add(createTerrainTable());
                setupTerrainCommands(terrainDa, m_conn);

                ds.Tables.Add(createLandTable());
                setupLandCommands(landDa, m_conn);

                ds.Tables.Add(createLandAccessListTable());
                setupLandAccessCommands(landAccessListDa, m_conn);

                ds.Tables.Add(createRegionSettingsTable());
                
                setupRegionSettingsCommands(regionSettingsDa, m_conn);

                // WORKAROUND: This is a work around for sqlite on
                // windows, which gets really unhappy with blob columns
                // that have no sample data in them.  At some point we
                // need to actually find a proper way to handle this.
                try
                {
                    shapeDa.Fill(ds.Tables["primshapes"]);
                }
                catch (Exception)
                {
                    m_log.Info("[REGION DB]: Caught fill error on primshapes table");
                }

                try
                {
                    terrainDa.Fill(ds.Tables["terrain"]);
                }
                catch (Exception)
                {
                    m_log.Info("[REGION DB]: Caught fill error on terrain table");
                }

                try
                {
                    landDa.Fill(ds.Tables["land"]);
                }
                catch (Exception)
                {
                    m_log.Info("[REGION DB]: Caught fill error on land table");
                }

                try
                {
                    landAccessListDa.Fill(ds.Tables["landaccesslist"]);
                }
                catch (Exception)
                {
                    m_log.Info("[REGION DB]: Caught fill error on landaccesslist table");
                }

                try
                {
                    regionSettingsDa.Fill(ds.Tables["regionsettings"]);
                }
                catch (Exception)
                {
                    m_log.Info("[REGION DB]: Caught fill error on regionsettings table");
                }
                return;
            }
        }