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
XMMImporter Plugin/General MediaModule -- Help Needed
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: 71899" data-attributes="member: 23814"><p><strong>SQLite Problems</strong></p><p></p><p>I'm having some issues with SQLite and my class. Here is a portion of a class that I wrote called VIDEO_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> m_db = new SQLiteClient("VideoDatabaseV5.db3");</p><p></p><p>with the exception</p><p></p><p>{"Object reference not set to an instance of an object."}</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></p><p>---- VIDEO_DB class -----</p><p>namespace GUIXMM</p><p>{</p><p> /// <summary></p><p> /// Class VIDEO_DB description</p><p> /// </summary></p><p> public class VIDEO_DB</p><p> {</p><p> public bool op_update = false;</p><p> public bool op_copy = false;</p><p> public bool op_image = false;</p><p> public bool op_format = true;</p><p> public bool op_actorInfo = false;</p><p> public int op_actorNum = 1;</p><p> public bool stopRebuild = false;</p><p> public ProgressBar progressBar = null;</p><p> public Label label1 = null;</p><p> public Label label2 = null;</p><p> </p><p> //private static SQLiteClient m_db = null;</p><p> public SQLiteClient m_db = null;</p><p> //SQLiteClient m_db;</p><p> //IDbConnection dbcon = null;</p><p> //private static string m_db = null;</p><p></p><p> private bool dbExists;</p><p></p><p> //------------------------------------------------------------------------------</p><p> // Open DB and initialize tables</p><p> //------------------------------------------------------------------------------</p><p> public void Open()</p><p> {</p><p> //SQLiteClient m_db;</p><p> //SQLiteResultSet results;</p><p> //SQLiteClient m_db = null;</p><p></p><p> try</p><p> {</p><p> // Open database</p><p> MessageBox.Show("Open DB");</p><p> //System.IO.Directory.CreateDirectory("database");</p><p> //dbExists = System.IO.File.Exists(@"database\VideoDatabaseV5.db3");</p><p></p><p> string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\";</p><p> string database = fullpath + "database\\VideoDatabaseV5.db3";</p><p> dbExists = System.IO.File.Exists(database);</p><p></p><p> Console.WriteLine("dBExists: " + dbExists.ToString());</p><p></p><p> //m_db = new SQLiteClient("test.db");</p><p> m_db = new SQLiteClient("VideoDatabaseV5.db3");</p><p> //m_db = new SQLiteClient(@"database\VideoDatabaseV5.db3");</p><p> //m_db = new SQLiteClient(database);</p><p></p><p></p><p> ArrayList tables = m_db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'");</p><p> foreach (string tableName in tables)</p><p> {</p><p> Console.WriteLine("\t" + tableName);</p><p> }</p><p></p><p></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>--- Test Function to create instance of VIDEO_DB class and open DB ----</p><p> 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> }</p></blockquote><p></p>
[QUOTE="Hesse, post: 71899, member: 23814"] [b]SQLite Problems[/b] I'm having some issues with SQLite and my class. Here is a portion of a class that I wrote called VIDEO_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 m_db = new SQLiteClient("VideoDatabaseV5.db3"); with the exception {"Object reference not set to an instance of an object."} I thought that I was setting the instance there?? Can anyone help me out? Regards, Jesse ---- VIDEO_DB class ----- namespace GUIXMM { /// <summary> /// Class VIDEO_DB description /// </summary> public class VIDEO_DB { public bool op_update = false; public bool op_copy = false; public bool op_image = false; public bool op_format = true; public bool op_actorInfo = false; public int op_actorNum = 1; public bool stopRebuild = false; public ProgressBar progressBar = null; public Label label1 = null; public Label label2 = null; //private static SQLiteClient m_db = null; public SQLiteClient m_db = null; //SQLiteClient m_db; //IDbConnection dbcon = null; //private static string m_db = null; private bool dbExists; //------------------------------------------------------------------------------ // Open DB and initialize tables //------------------------------------------------------------------------------ public void Open() { //SQLiteClient m_db; //SQLiteResultSet results; //SQLiteClient m_db = null; try { // Open database MessageBox.Show("Open DB"); //System.IO.Directory.CreateDirectory("database"); //dbExists = System.IO.File.Exists(@"database\VideoDatabaseV5.db3"); string fullpath = "C:\\Program Files\\Team MediaPortal\\MediaPortal\\"; string database = fullpath + "database\\VideoDatabaseV5.db3"; dbExists = System.IO.File.Exists(database); Console.WriteLine("dBExists: " + dbExists.ToString()); //m_db = new SQLiteClient("test.db"); m_db = new SQLiteClient("VideoDatabaseV5.db3"); //m_db = new SQLiteClient(@"database\VideoDatabaseV5.db3"); //m_db = new SQLiteClient(database); ArrayList tables = m_db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'"); foreach (string tableName in tables) { Console.WriteLine("\t" + tableName); } 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); } } --- Test Function to create instance of VIDEO_DB class and open DB ---- 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(); } [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
XMMImporter Plugin/General MediaModule -- Help Needed
Contact us
RSS
Top
Bottom