NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 71 72 73 74 75 … 93 Next »
current show from database

 
  • 0 Vote(s) - 0 Average
current show from database
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#1
2005-05-01, 12:56 PM
im trying to get the current tv show from the database using this code
Code:
OleDbConnection conn = new OleDbConnection(GBPVRDB_CONNECTION_STRING);    

            OleDbCommand cmd = new OleDbCommand("SELECT name, subtitle FROM PROGRAMME WHERE start_time >= @Start AND end_time < @End",conn);
            
            cmd.Parameters.Add("@Start", Sy{tem.DateTime.Now);
            command.Parameters.Add("@End", System.DateTime.Now);
            
            conn.Open();
            OleDbDataReader reader = cmd.ExecuteReader();
            string title = "";
            string subtitle = "";
            while(reader.Read())
            {
                title = reader.GetString(0);
                subtitle = reader.GetString(1);
            }
            conn.Close();

but i keep getting this error
Code:
2/05/2005 12:53:22 a.m..782    ERROR    [2]    Error: msg=0x100 (WM_KEYDOWN) hwnd=0x370254 wparam=0x71 lparam=0x1 result=0x0   :  No value given for one or more required parameters.   :     at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.OleDb.OleDbCommand.ExecuteReader()
   at LCDPlugin.Database.GetShow(String oid) in c:\xmltv\my lcd\database.cs:line 59

the problem is to do with the @Start and @End datetimes, im not sure how im meant to set this, anyone know where im going wrong?

TIA
reven.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#2
2005-05-01, 01:31 PM
oh i forgot to add where oid=@oid to the command string, but that hasnt got anything to do with the error Smile
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#3
2005-05-01, 04:56 PM
sub_title not subtitle
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#4
2005-05-01, 09:00 PM
ok that solved that problem, now im getting a datatype mismatch
Code:
2/05/2005 8:58:28 a.m..766    ERROR    [2]    Error: msg=0x100 (WM_KEYDOWN) hwnd=0x57021a wparam=0x71 lparam=0x1 result=0x0   :  Data type mismatch in criteria expression.   :     at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.OleDb.OleDbCommand.ExecuteReader()
   at LCDPlugin.Database.GetShow(String oid) in c:\xmltv\my lcd\database.cs:line 42
im pretty sure its with the dates (well thats the only thing to be mismatched Smile), theres just so many different date types, but i think datetime is the correct one to pass.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#5
2005-05-01, 09:18 PM
Whats on c:\xmltv\my lcd\database.cs:line 42?
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#6
2005-05-01, 09:22 PM
just the cmd.executereader(); which doesnt help any..

i removed the end_time < @end and it worked, so i think thats whats wrong, ill look in the db again for the column name../
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#7
2005-05-01, 09:25 PM
nope end_time is the correct column name

heres the complete code im working with now
Code:
public Show GetShow(int oid)
{
if(oid < 0)
return new Show("","");

OleDbConnection conn = new OleDbConnection(GBPVRDB_CONNECTION_STRING);                
OleDbCommand cmd = new OleDbCommand("SELECT name, sub_title FROM PROGRAMME WHERE start_time >= @Start AND end_time < @End AND oid=@oid",conn);
            
cmd.Parameters.Add("@Start", System.DateTime.Now);
cmd.Parameters.Add("@End", System.DateTime.Now);
cmd.Parameters.Add("@oid", oid);
            
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
string title = "";
string subtitle = "";
while(reader.Read())
{
title = reader.GetString(0);
subtitle = reader.GetString(1);
}
conn.Close();
            
return new Show(title, subtitle);
}

oh and does a event get fired on a channel change and show change (ie when a show finishes and a new one starts, otherwise i thinking i might be wasting my time...)
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#8
2005-05-01, 09:59 PM
problem solved with:
System.DateTime.Now.ToString();

for some reason it didnt like the datetime object, but fine with the string dd/mm/yyyy hh:mmConfuseds am/pm

Smile

channel change updates the display, now just got to wait for a end of a show to see if it gets updated Smile
« Next Oldest | Next Newest »

Users browsing this thread: 2 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Artwork by show name psycik 4 4,495 2017-07-12, 03:47 AM
Last Post: psycik
  Show artwork method psycik 31 11,655 2015-07-14, 07:06 AM
Last Post: aloxinh
  Media\Show Directory mvallevand 12 6,004 2014-07-02, 10:58 AM
Last Post: sub
  Delete recordings from database but not from disk? spinnaker 8 3,748 2013-10-26, 10:51 PM
Last Post: spinnaker
  trying to fake npvr database for unit tests reven 3 2,237 2013-05-20, 08:53 AM
Last Post: reven
  sabnzbd plugin to show processed files Wakalaka 1 1,932 2013-03-12, 06:48 AM
Last Post: psycik
  Album art. Current conventions? bgowland 2 1,580 2012-12-21, 02:08 AM
Last Post: bgowland
  Merged database queries mvallevand 4 2,050 2011-06-26, 09:56 PM
Last Post: mvallevand
  NPVR database questions mvallevand 25 9,776 2011-01-06, 12:58 AM
Last Post: jksmurf
  NPVR database - why so stringy with the fields?? :0) carpeVideo 4 1,985 2010-09-21, 01:48 AM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode