Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Moesat · May 11, 2017 at 02:12 PM · databasesqlite

My database is not working after build and run !

The sqldatabase is working fine when I run in editor but it does not work after build. This problem started happen after updated the unity to 5.6.0f3 from old one. The sql script is as below. I have tired all I can do.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using Mono.Data.Sqlite;
 using System;
 using System.Data;
 
 public class DataStorage : MonoBehaviour
 {
     public V v;
 
     string conn;
     int CheckOk = 0;
 
     private string Answer;
 
     public string Load(string Code)
     {
         if (Code.Length != 0)
         {
             CheckOk = 0;
             int x = Int32.Parse(Code);
             StartCoroutine(Wait());
             IDbConnection dbconn;
             dbconn = (IDbConnection)new SqliteConnection(conn);
             dbconn.Open(); //Open connection to the database.
             IDbCommand dbcmd = dbconn.CreateCommand();
             string sqlQuery = "SELECT Code,Ans FROM Answers";
             //string sqlQuery = "CREATE TABLE IF NOT EXISTS Answers (Code INTEGER NOT NULL PRIMARY KEY, Ans VARCHAR(40))";
             dbcmd.CommandText = sqlQuery;
             IDataReader reader = dbcmd.ExecuteReader();
             while (reader.Read())
             {
                 int CodeM = reader.GetInt32(0);
                 string Ans = reader.GetString(1);
                 if (x == CodeM)
                 {
                     Answer = Ans;
                     CheckOk = 1;
                     break;
                 }
             }
             if (CheckOk == 0)
             {
                 Answer = "I don't know what you mean.";
             }
             reader.Close();
             reader = null;
             dbcmd.Dispose();
             dbcmd = null;
             dbconn.Close();
             dbconn = null;
         }
         else
         {
             Answer = "I don't know what you mean.";
         }
         return (Answer);
     }
 
     public void Save(string Code,string Ans)
     {
         int x = Int32.Parse(Code);
         Debug.Log(x);
         StartCoroutine(Wait());
         IDbConnection dbconn;
         dbconn = (IDbConnection)new SqliteConnection(conn);
         dbconn.Open(); //Open connection to the database.
         IDbCommand dbcmd = dbconn.CreateCommand();
         string sqlAdd = "INSERT INTO Answers VALUES('" + x + "','" + Ans + "')";
         dbcmd.CommandText = sqlAdd;
         IDataReader reader = dbcmd.ExecuteReader();
         reader.Close();
         reader = null;
         dbcmd.Dispose();
         dbcmd = null;
         dbconn.Close();
         dbconn = null;
     }
 
     private IEnumerator Wait()
     {
         conn = "URI=file:" + Application.dataPath + "/StreamingAssets/Memory.db"; //Path to database.
         v.SystemLogEditor(conn);
         Debug.Log(conn);
         yield return conn;
     }
 
 }

This is on editor. This is on editor.

This is after build. This is after build. As you can see, there is no reply log in system log. Please help me.

v1.jpg (123.1 kB)
v2.jpg (141.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Moesat · May 16, 2017 at 04:27 AM

Oh! It solved! I re-imported the sqlite3.dll file from this link and it works fine. Here the link to get the zip file of Sqlite3.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Moesat · May 16, 2017 at 04:31 AM 0
Share

This time, database not work in editor.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

105 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Moving a file from the project folder to the data directory at runtime 1 Answer

iOS can't connect to SQLite DB 1 Answer

SQLite with JPG blob 0 Answers

login system in unity w/ SQLite 0 Answers

Can sqlite sync with database online? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges