home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
SQLite error - Please Help
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Hesse" data-source="post: 72167" data-attributes="member: 23814"><p>I'm having some issues with SQLite and my class. Here is a portion of a class that I wrote called GENERAL_DB which is supposed to be the class which can access the SQLite DB. I have a separate test block of code which attempts to create an instance of this class and open the database as shown.</p><p></p><p>However, when I run the code, I get an exception that I can't understand why its occurring. When I run in debug mode and step through, it bombs on the line</p><p></p><p>[CODE]m_db = new SQLiteClient(databaseFile);[/CODE]</p><p></p><p>with the exception</p><p></p><p>[CODE]{"Object reference not set to an instance of an object."}[/CODE]</p><p></p><p>I thought that I was setting the instance there?? Can anyone help me out?</p><p></p><p>Regards,</p><p></p><p>Jesse</p><p></p><p></p><p>--- GENERAL_DB class ----</p><p></p><p>[CODE]using System;</p><p>using System.Data;</p><p>using System.Collections.Generic;</p><p>using System.Collections;</p><p>using System.Text;</p><p>using System.Windows.Forms;</p><p>using MediaPortal.Database;</p><p>using SQLite.NET;</p><p></p><p></p><p>namespace GUIXMM</p><p>{</p><p> public class GENERAL_DB</p><p> {</p><p> public SQLiteClient m_db = null;</p><p> private bool dbExists;</p><p></p><p> public GENERAL_DB()</p><p> {</p><p> }</p><p></p><p> public void Open()</p><p> {</p><p> </p><p></p><p> // Attempt to open database</p><p> try</p><p> {</p><p> // Open database</p><p> MessageBox.Show("Open DB");</p><p></p><p> string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\";</p><p> string databaseFile = fullpath + "database\\VideoDatabaseV5.db3";</p><p> dbExists = System.IO.File.Exists(databaseFile);</p><p></p><p> Console.WriteLine("dBExists: " + dbExists.ToString());</p><p></p><p> m_db = new SQLiteClient(databaseFile);</p><p></p><p> if (!dbExists)</p><p> {</p><p> Console.WriteLine("DB does not exist, creating tables.");</p><p> //CreateTables();</p><p> }</p><p> }</p><p> catch (SQLiteException ex)</p><p> {</p><p> Console.WriteLine("Fatal error: {0}", ex.Message);</p><p> //Log.Write("XMMdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);</p><p> }</p><p> }</p><p></p><p> }</p><p>}[/CODE]</p><p></p><p></p><p></p><p></p><p>--- Separate function to create instance of GENERAL_DB ----</p><p></p><p>[CODE] private void button_debug_VIDEO_DB_Click(object sender, EventArgs e)</p><p> {</p><p> string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\";</p><p></p><p> string database = fullpath + "database\\VideoDatabaseV5.db3";</p><p> //MessageBox.Show(database);</p><p></p><p> if (File.Exists(database))</p><p> {</p><p> MessageBox.Show("File: " + database + " exists");</p><p> }</p><p> else</p><p> {</p><p> MessageBox.Show("File: " + database + "was not found.");</p><p> }</p><p></p><p> //VIDEO_DB myVIDEO_DB = new VIDEO_DB();</p><p> //myVIDEO_DB.Open();</p><p></p><p> GENERAL_DB myGENERAL_DB = new GENERAL_DB();</p><p> myGENERAL_DB.Open();</p><p></p><p> }[/CODE]</p></blockquote><p></p>
[QUOTE="Hesse, post: 72167, member: 23814"] I'm having some issues with SQLite and my class. Here is a portion of a class that I wrote called GENERAL_DB which is supposed to be the class which can access the SQLite DB. I have a separate test block of code which attempts to create an instance of this class and open the database as shown. However, when I run the code, I get an exception that I can't understand why its occurring. When I run in debug mode and step through, it bombs on the line [CODE]m_db = new SQLiteClient(databaseFile);[/CODE] with the exception [CODE]{"Object reference not set to an instance of an object."}[/CODE] I thought that I was setting the instance there?? Can anyone help me out? Regards, Jesse --- GENERAL_DB class ---- [CODE]using System; using System.Data; using System.Collections.Generic; using System.Collections; using System.Text; using System.Windows.Forms; using MediaPortal.Database; using SQLite.NET; namespace GUIXMM { public class GENERAL_DB { public SQLiteClient m_db = null; private bool dbExists; public GENERAL_DB() { } public void Open() { // Attempt to open database try { // Open database MessageBox.Show("Open DB"); string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\"; string databaseFile = fullpath + "database\\VideoDatabaseV5.db3"; dbExists = System.IO.File.Exists(databaseFile); Console.WriteLine("dBExists: " + dbExists.ToString()); m_db = new SQLiteClient(databaseFile); if (!dbExists) { Console.WriteLine("DB does not exist, creating tables."); //CreateTables(); } } catch (SQLiteException ex) { Console.WriteLine("Fatal error: {0}", ex.Message); //Log.Write("XMMdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); } } } }[/CODE] --- Separate function to create instance of GENERAL_DB ---- [CODE] private void button_debug_VIDEO_DB_Click(object sender, EventArgs e) { string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\"; string database = fullpath + "database\\VideoDatabaseV5.db3"; //MessageBox.Show(database); if (File.Exists(database)) { MessageBox.Show("File: " + database + " exists"); } else { MessageBox.Show("File: " + database + "was not found."); } //VIDEO_DB myVIDEO_DB = new VIDEO_DB(); //myVIDEO_DB.Open(); GENERAL_DB myGENERAL_DB = new GENERAL_DB(); myGENERAL_DB.Open(); }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
SQLite error - Please Help
Contact us
RSS
Top
Bottom