Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
It correctly creates the Users table in the second (destination) .db database, however it does not populate it with the data of the Users table of the original .db database. The two tables are identical. None of them actually even have a primary key set. I need to copy the data from the original table to the destination table.
I have tried the following, without success for the copy part:
public class DatabaseAccess { private static string _connDatabaseStringUsers = "URI=file:c:/TSV3/TS" + "DemoUsers" + ".db; Version=3; Journal Mode=Off; Synchronous=Off;"; }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using System.Net; using System.Net.Sockets; using System.Text; using System.Linq; using Mono.Data.Sqlite; using System.IO; using System.Data; using System; public class GameInstance : Singleton<GameInstance> { private SqliteConnection _conn4; private SqliteConnection _conn5; public void Start() { CreateTable(); } public void CreateTable() { _conn4 = new SqliteConnection(DatabaseAccess.ConnDatabaseStringUsers); _conn4.Open(); try { SqliteCommand cmd4 = new SqliteCommand("CREATE TABLE IF NOT EXISTS Users ('ID' INTEGER, 'FileNumber' TEXT, 'FamilyName' TEXT, 'Name' TEXT, 'ParentFolderID' INTEGER, 'AvatarSex' INTEGER, 'Role' INTEGER)", _conn4); cmd4.ExecuteNonQuery(); } catch (UnityException e) { Debug.LogError(e); } finally { _conn4.Close(); } CopyTable(); } public void CopyTable() { _conn5 = new SqliteConnection(DatabaseAccess.ConnDatabaseStringUsers); _conn5.Open(); try { SqliteCommand cmd5 = new SqliteCommand("SELECT * INTO Users IN 'TSDemo.db' FROM Users", _conn5); cmd5.ExecuteNonQuery(); } catch (UnityException e) { Debug.LogError(e); } finally { _conn5.Close(); } } }
I expect the data from the table Users from the first .db database to be copied to the table Users from the second .db database, but it's not the case. However, Unity does not throw me any error. The table is being created, but data is not populated into it.
Since SQLite doesn't support select into, you could either use create table as select if the table doesn't exist:
select into
create table as select
create table dest as select * from source
Or insert into select if the table exists or you create it:
insert into select
insert into dest select * from source
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.