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 /
avatar image
0
Question by Farwall · Sep 26, 2016 at 08:26 PM · databasesqlite

SQLite Database is not working after standalone build

I am trying to make a Standalone Application using SQLite in Unity3D, I am getting a strange problem. I created a database using sqliteadmin, and created a Table named Admin, having field: id, email, password.

I am able to Login using email and password but in Unity Edit Mode.

Its working fine but when i build it and then run it, its not working, I have no idea why?

Reference

Here is my code:

using UnityEngine; using System.Collections; using Mono.Data.Sqlite; using System.Data; using System; using UnityEngine.UI;

public class DatabaseConnection : MonoBehaviour {

 public Text em;
 public Text pas;
 public static int id;
 public static string email ="";
 public static string conn ="";
 public static string password="";
 public static string wrong="Wrong Email/Password !!!";
 public Text Wrong;
 public GameObject loading;
 private ButtonsController bc;
 public GameObject loginPanel;

 void Start () {

     conn = "URI=file:" + Application.dataPath + "/TMDB.s3db";
     IDbConnection dbconn;
     dbconn = (IDbConnection)new SqliteConnection (conn);
     dbconn.Open ();
     IDbCommand dbcmd = dbconn.CreateCommand ();
     string sqlQuery = "SELECT id, email, password " + "FROM Admin";
     dbcmd.CommandText = sqlQuery;
     IDataReader reader = dbcmd.ExecuteReader ();
     while (reader.Read()) {
          id = reader.GetInt32 (0);
          email = reader.GetString(1);
          password = reader.GetString(2);
         
         Debug.Log (conn);

     }
     reader.Close ();
     reader = null;
     dbcmd.Dispose ();
     dbcmd = null;
     dbconn.Close ();
     dbconn = null;
     loading.SetActive (false);
 }

 public void login()
 {
     if ((em.text == email) && (pas.text == password)) {
         Debug.Log ("Success");
         loading.SetActive (true);
         loginPanel.SetActive(false);
     } else {
         Debug.Log ("Error");
         Wrong.text = wrong.ToString ();
     }
 }

}

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
0

Answer by navidhaghighi · Nov 10, 2018 at 09:24 AM

i had the same problem a while ago. go to your build folder under "Build_Data" folder , there's your database file , if you have same problem as mine , it should have a size of 0 KB , because it's empty. copy the database file from your project , and paste it in your "Build_Data" folder.

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 Cranch1 · Aug 18, 2020 at 03:34 PM 0
Share

Thats what I got my students to do and it works properly. If you populate your database through an SQL file you can run that as the SQL command at start and it will populate the database first time but the above option is much easier.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with SQLite unity Database 0 Answers

why sqlite can't conneted after build in PC (.exe) 0 Answers

Deleting the main database at runtime. 0 Answers

Database not loaded on Device, but works on Unity Game Scene 1 Answer

Help with SQLite for Android Errors in Unity3D? 1 Answer


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