N
N
nika092017-06-07 10:00:19
SQL
nika09, 2017-06-07 10:00:19

What's wrong with the database?

473c283159364d4ebfad66ecc1b319b9.pngThere is a youtube.bytes database in it with a Users table with 3 fields, I try to send and read records there, neither one nor the other comes out, basically the error is Unable to open Assets/youtube.bytes.db: Check external application preferences. there is a try to display an error through try catch writes Mono.Data.Sqlite.SqliteE
how to solve the problem?
SqliteException: SQLite error
no such table: Users
Mono.Data.Sqlite.SQLite3.Prepare(Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain)
Mono.Data.Sqlite.SqliteCommand.BuildNextCommand()
UnityEngine.EventSystems.EventSystem:Update()

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


public class db_controller : MonoBehaviour {

  public SqliteConnection con_db;
  public SqliteCommand cmd_db;
  public SqliteDataReader rdr;

  public string path;
  public Text text;

string id;
string log;
string pass;

public InputField idfield;
public InputField login;
public InputField password;


  // Use this for initialization
  void Start () {
    
  }
  
  // Update is called once per frame
  void Update () {
    
  }

  public void Connection()
  {			
    path = Application.dataPath + "/youtube.bytes";
    con_db = new SqliteConnection ("URI=file:" + path);
    con_db.Open ();
    
  }
  public void SetDB(){
  Connection();
  id=idfield.text.ToString();
    log=login.text.ToString();
    pass=password.text.ToString();

    cmd_db=new SqliteCommand("INSERT INTO Users(id,login,pass) VALUES('"+id+"','"+log+"','"+pass+"')", con_db);
    cmd_db.ExecuteNonQuery ();
    Disconnect();
}
  private void Disconnect(){
    con_db.Close ();
  }


}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nika09, 2017-06-07
@nika09

The issue was resolved by changing the db extension

D
Dmitry Eremin, 2017-06-07
@EreminD

Unable to open Assets/youtube.bytes.db: Check external application preferences

Well, it doesn't seem to be a bug in the code...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question