Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Link huong dan: http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.html
- using UnityEngine;
- using System.Collections;
- using Mono.Data.Sqlite;
- using System.Data;
- using System;
- public class XuLy : MonoBehaviour {
- // Use this for initialization
- void Start () {
- Debug.Log ("Thieu Mao");
- string conn = "URI=file:" + Application.dataPath + "/PickAndPlaceDatabase"; //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;
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment