VB .NET Plugin: sqlite.dll Error (3 Viewers)

STSC

Portal Pro
December 4, 2004
139
0
Germany
Hi,

I'm trying to program a plugin for MP in VB .NET.
I added all of the .dlls of the MP directory.

My SourceCode is like this:

Dim recordings As New ArrayList
Dim recording As New MediaPortal.TV.Database.TVRecording
MediaPortal.TV.Database.TVDatabase.GetRecordings(recordings)

Now I get inside sqlclient.dll this error:
System.DllNotFoundException (sqlite.dll)

Does anybody know what the issue is?
 
A

Anonymous

Guest
Make sure that sqlite.dll and SQLiteClient.dll are in the same directory as your .exe. If you are creating a plugin and trying to run it from MP, it should have found it since the dlls are in the home directory of MP
 

STSC

Portal Pro
December 4, 2004
139
0
Germany
Actually it is more like an external program (PVR Scheduler). I added all the references and put
sqlite.dll into my /bin directory of my project. The other .dll like core.dll, SQLiteClient.dll ... were put automatically into my /bin folder, when I compiled it.
The only strange thing is that it also creates into /bin a log and a empty database folder?
In the log folder there is the mediaportal.log file:

15.12.2004 21:29:39 opening tvdatabase
15.12.2004 21:29:39 TVDatabase exception err:Die DLL (sqlite.dll) kann nicht geladen werden. stack: at SQLite.NET.SQLiteClient.sqlite_open(String filename, Int32 mode, String& errmsg)
at SQLite.NET.SQLiteClient..ctor(String dbName)
at MediaPortal.TV.Database.TVDatabase..cctor()
15.12.2004 21:29:39 tvdatabase opened
 
A

Anonymous

Guest
try copying the databases from the database directory to your database directory. The problem is that it is trying to open the dbs but it can't find them...
 

STSC

Portal Pro
December 4, 2004
139
0
Germany
OK. I know now what it doesn't work:

Code:
    private TVDatabase()
    {
    }

    /// <summary>
    /// static constructor. Opens or creates the tv database from database\TVDatabaseV6.db
    /// </summary>
    static TVDatabase()
    {
      lock (typeof(TVDatabase))
      {
        try 
        {
          // Open database
          Log.Write("opening tvdatabase");
          System.IO.Directory.CreateDirectory("database");
          //Upgrade();
          m_db = new SQLiteClient(@"database\TVDatabaseV9.db");
          CreateTables();

          if (m_db!=null)
          {
            m_db.Execute("PRAGMA cache_size=8192\n");
            m_db.Execute("PRAGMA synchronous='OFF'\n");
            m_db.Execute("PRAGMA count_changes='OFF'\n");
          }

        } 
        catch (Exception ex) 
        {
          Log.Write("TVDatabase exception err:{0} stack:{1}", ex.Message,ex.StackTrace);
        }
        Log.Write("tvdatabase opened");
      }
    }


Code:
static public bool GetRecordings(ref ArrayList recordings)
    {
      lock (typeof(TVDatabase))
      {
        recordings.Clear();
        try
        {
          if (null==m_db) return false;
          string strSQL;
          strSQL=String.Format("select * from channel,recording where recording.idChannel=channel.idChannel order by iStartTime");
          SQLiteResultSet results;
          results=m_db.Execute(strSQL);
          if (results.Rows.Count== 0) return false;
          for (int i=0; i < results.Rows.Count;++i)
          {
            long iStart=Int64.Parse(Get(results,i,"recording.iStartTime"));
            long iEnd=Int64.Parse(Get(results,i,"recording.iEndTime"));
            TVRecording rec=new TVRecording ();
            rec.Channel=Get(results,i,"channel.strChannel");
            rec.Start=iStart;
            rec.End=iEnd;
            rec.Canceled = Int64.Parse(Get(results,i,"recording.iCancelTime"));
            rec.ID=Int32.Parse(Get(results,i,"recording.idRecording"));
            rec.Title=Get(results,i,"recording.strProgram");
            rec.RecType=(TVRecording.RecordingType)Int32.Parse(Get(results,i,"recording.iRecordingType"));
						int iContectRec=Int32.Parse(Get(results,i,"recording.bContentRecording"));
						if (iContectRec==1) rec.IsContentRecording=true;
						else rec.IsContentRecording=false;
            recordings.Add(rec);
          }

          return true;
        }
        catch(SQLiteException ex)
        {
          Log.Write("TVDatabase exception err:{0} stack:{1}", ex.Message,ex.StackTrace);
        }
        return false;
      }
    }

The reasen is that I can't initiate a new TVDatabase, which opens the database:

Should be like:
Dim tvb As New MediaPortal.TV.Database.TVDatabase

TVDatabase is private!!

But I have to insanciate m_db, in order to get it work.

Either frodo can change this or I have to program my own SQLite subroutines, but then I don't know if MP supports multi user access.

frodo Can you please give me a hint!

Thanks!!
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
Nope, you can use it without any changes.

The keyword is static. In VB.NET lingo, this translates to shared.

Therefore, this class cannot be and doesn't need to be instantiated because there can only ever be one instance of it - its singleton.

To access the methods, simply go MediaPortal.TV.Database.TVDatabase.AddRecording or whatever.

Keep in mind that the method can only ever be accessed by one call at a time, shown by the lock (typeof(TVDatabase)) statement. So if MP happens to be using the TVdatabase, then your plugin will have to wait until MP finishes before you can use it.

The database itself however does allow multiple user access, so if you want to can connect directly to the database file. BTW, if you do choose this way and you want to use ADO.NET work SQLite, there is a dll that lets you do this. See http://sourceforge.net/projects/adodotnetsqlite.

Sam
 

STSC

Portal Pro
December 4, 2004
139
0
Germany
Thank you for the information.

But I can't simple access the methods like this:

Dim recordings As New ArrayList
Dim recording As New MediaPortal.TV.Database.TVRecording
MediaPortal.TV.Database.TVDatabase.GetRecordings(recordings)

Do you know the issue?

I already know
http://sourceforge.net/projects/adodotnetsqlite
and this is what I wanted to use when I don't get access to the MP methods

Anyway I think that MP uses these libraries:
http://www.phpguru.org/static/SQLite.NET.html
But I don't know if these libs also work in VB .NET
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
What happens when you use that code?

Keep in mind that if you want to access the recording objects in the arraylist, you have to convert the type, e.g.

Code:
Dim recordings As New ArrayList
MediaPortal.TV.Database.TVDatabase.GetRecordings(recordings) 

Dim recording As MediaPortal.TV.Database.TVRecording
recording = cType(recordings(0), MediaPortal.TV.Database.TVRecording)
recording.Title or whatever...

Sam
 

STSC

Portal Pro
December 4, 2004
139
0
Germany
This doesn't work.
I already get an false return value of MediaPortal.TV.Database.TVDatabase.GetRecordings(recordings)
!
MessageBox.Show(MediaPortal.TV.Database.TVDatabase.GetRecordings(recordings))
 

Users who are viewing this thread

Top Bottom