• 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 /
This question was closed Jul 08, 2014 at 10:03 AM by tanoshimi for the following reason:

The question is answered, right answer was accepted

avatar image
85
Question by Adorable73 · Jul 08, 2014 at 09:49 AM · databasesqlitestorage

Database (SQLite) Setup for Unity

  1. Create new folder under Assets Folder Rename it Plugins .

  2. Copy sqlite3.def and sqlite3.dll into Assets/Plugins in your unity project .You can download these files here http://www.sqlite.org/download.html for windows (Precompiled Binaries for Windows)

  3. Download SQLite Browser http://sourceforge.net/projects/sqlitebrowser/ or http://sqliteadmin.orbmu2k.de/ download SQLite Administrator tool

  4. Create Database in Assets folder in your unity project using SQLite Browser.

  5. Copy System.Data.dll and Mono.Data.Sqlite.dll from **C:\Program Files (x86)\Unity \Editor\Data\Mono\lib\mono\2.0* and paste them in your Assets/Plugins* folder in your unity project.

  6. Add these namespaces using Mono.Data.Sqlite; using System.Data; using System;

  7. string conn= "URI=file:" + Application.dataPath + "/PickAndPlaceDatabase.s3db";

Replace PickAndPlaceDatabase.s3db with your database name

void Start () {

     string conn = "URI=file:" + Application.dataPath + "/PickAndPlaceDatabase.s3db"; //Path to database.
     IDbConnection dbconn;
     dbconn = (IDbConnection) new SqliteConnection(conn);
     dbconn.Open(); //Open connection to the database.
     IDbCommand dbcmd = dbconn.CreateCommand();





     string sqlQuery = "SELECT value,name, randomSequence " + "FROM PlaceSequence";
     dbcmd.CommandText = sqlQuery;
     IDataReader reader = dbcmd.ExecuteReader();


     while (reader.Read())
     {
         int value = reader.GetInt32(0);
         string name = reader.GetString(1);
         int rand = reader.GetInt32(2);
        
         Debug.Log( "value= "+value+"  name ="+name+"  random ="+  rand);
     }

     reader.Close();
     reader = null;
     dbcmd.Dispose();
     dbcmd = null;
     dbconn.Close();
     dbconn = null;




 }



alt text

alt text

Further SQLite Help Visit : http://www.tutorialspoint.com/sqlite/

[1]: /storage/temp/28838-output.png

data.png (36.1 kB)
output.png (10.6 kB)
Comment
Add comment · Show 23
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 tarasfromlviv · Jul 08, 2014 at 09:57 AM 0
Share

Good stuff, but why making this a question?

avatar image Adorable73 · Jul 08, 2014 at 10:03 AM 1
Share

I have posted this ,to help others. I was searching some help form different resource youtube,google to setup database and at end i write this article to help others.

avatar image tanoshimi · Jul 08, 2014 at 10:04 AM 0
Share

Ok, I'm going to close it as answered then, because otherwise it will keep on appearing as an active question :)

avatar image tanoshimi · Aug 24, 2016 at 06:50 AM 0
Share
@tanoshimi I am also following you as well. I follow the same steps as you mentioned above and it is working well for the editor and i think also working well for the window phone because you have added the precompiled libraries for the window phone. It is working for the editor but i want to use it for the android as well as for IOS. I have already wasted one day on it and i hope you will guide me in a proper way. Thanks !
avatar image · Aug 24, 2016 at 06:55 AM 0
Share
@tanoshimi Waiting for your reply. I had just created the account just to get the answer of it. I had used more than twenty queries in my application and it is not working in the android as well as IOS phone. I am really fed up of this.Help me otherwise my ten days work will be lost. Thanks !
avatar image vmachupalli · Jul 08, 2014 at 10:04 AM 0
Share

This looks more like a TIP/Tutorial.Why is this posted here? do you see an issue ?

avatar image tonyvicb · Jul 16, 2015 at 03:45 PM 2
Share

thanks .. another thing sir how can i work it on android??

avatar image tonyvicb · Aug 24, 2016 at 06:59 AM 1
Share

Did you find the answer of it ? I am also finding the solution how to work in android. If you have solved it then guide me.

Show more comments

0 Replies

  • Sort: 

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

25 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

Related Questions

Sq lite Date base in unity 3d? 1 Answer

Alternative to storing data in DB's 2 Answers

how to access and modify my existing database made by DB browser for SQLite in unity after build 0 Answers

How to use asset bundle as database instead of PlayerPrefs 0 Answers

SQLite Query error 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges