Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Database to Listbox
PostPosted: August 22nd, 2007, 4:59 pm 
Offline

Joined: August 14th, 2005, 5:40 pm
Posts: 42
Location: Southampton (England)
Opus: Opus Pro 5, 6, 7 & 8
OS: Windows 7 32bit Pro / Windows 7 64bit Pro
System: Intel I7 350 Quad 3.33Ghz - 12 gig ddr3 - Nvidia GeForce GTX 480
Hi All
I have set up my database (Video data.dsn) and want to extract information and display in a listbox (Video_FileName and Video_Time). I have tried to edit some code I found on this forum, but I can't get it to work.

If you can see where i'm going wrong Please let me know

Code:
var db = new Database("FILEDSN=video data.dsn;")
var records = null;
var num_records = 0;

//////////////////////////////////////////////////////////////////////////////
//
// NOTE: Start_Record_Num is the record number for the first of the 5 records
//       and it is a Page Variable
//

function SearchDB()
{
   var sql = "SELECT * FROM Videos"
   // Debug.trace(sql+"\n");
   records = db.ExecuteSQL(sql);
   num_records = records.GetNumberOfRecords();
   numberrecords = num_records;
   ShowRecords();
}

function ShowRecords()
{
   if (records == null) {
      return;  // need to call Search First to get records
   }
   var list_box = Listbox_1;
   list_box.SetSelection(0, -1);   // Select all the old text
   list_box.ReplaceSelection("");   // Remove all the old text
   
   if (records.FirstRecord()) {
      list_box.ReplaceSelection(records.Video_FileName+"\t "+records.Video_Time);
      records.NextRecord();
      for (i=1; i<num_records; i++) {
         list_box.ReplaceSelection("\n"+records.Video_FileName+"\t "+records.Video_Time);
         records.NextRecord();
      }
   }


Thanks
Mark

_________________
======================
www.networkentertainment.co.uk


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 22nd, 2007, 7:36 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Netty,

Yes this has been posted before, the solution I gave, which apparently worked, was to read the recordset into a string with a line break at the end of each record. Then pass this to the listbox replace.


Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Database to Listbox
PostPosted: August 23rd, 2007, 10:14 am 
Offline

Joined: August 14th, 2005, 5:40 pm
Posts: 42
Location: Southampton (England)
Opus: Opus Pro 5, 6, 7 & 8
OS: Windows 7 32bit Pro / Windows 7 64bit Pro
System: Intel I7 350 Quad 3.33Ghz - 12 gig ddr3 - Nvidia GeForce GTX 480
Hi Mack

have you got any ideas why the code is not working?

Database Name : Video data.dns

Fields To list : Video_FileName & Video_Time

My Listbox is called Listbox_1

Thanks for your help

Mark

_________________
======================
www.networkentertainment.co.uk


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 23rd, 2007, 3:12 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Netty,

As I said above, you need to read the recordset into a variable using \n to insert the line.

THEN select the listbox text and replace this with the variable about.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 23rd, 2007, 5:01 pm 
Offline

Joined: August 14th, 2005, 5:40 pm
Posts: 42
Location: Southampton (England)
Opus: Opus Pro 5, 6, 7 & 8
OS: Windows 7 32bit Pro / Windows 7 64bit Pro
System: Intel I7 350 Quad 3.33Ghz - 12 gig ddr3 - Nvidia GeForce GTX 480
Hi Mack

thanks for yor reply i'll give it another go

Mark

_________________
======================
www.networkentertainment.co.uk


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group