Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently September 29th, 2024, 7:14 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Database variable
PostPosted: July 25th, 2005, 9:23 pm 
Offline

Joined: April 1st, 2005, 6:59 pm
Posts: 98
Location: Maastricht, The Netherlands
Opus: V7
OS: Mac OS X 10.7.2 | Windows 8 Dev
System: i5 2.7 | 8G Ram | 1 T HD
Hi,

Is it possible to set an input field to act like a search string as in a standard application, to search in a dBase data-base?

Search by:
*.*
?
*partoftext*
etc.

Thanks for any help

Ronnie Dackus


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 27th, 2005, 3:28 pm 
Offline

Joined: June 29th, 2005, 9:39 pm
Posts: 9
Ronnie,
You should be able to do it using a variation of this sqlStatement. Set your textbox equal to the variable TempInput. I'm not sure what the search chars are in dBase, but the concept should be the same.

Rset = myDB.ExecuteSQL("SELECT * FROM tblLesson1 WHERE PriText LIKE '%" + TempInput + "%'")

If you want more than 1 search option, use the FindText function to check for
your search characters and if/else statements to determine which option to run.

Hope this helps
Jason


Top
 Profile  
 
 Post subject: Error
PostPosted: July 27th, 2005, 5:50 pm 
Offline

Joined: April 1st, 2005, 6:59 pm
Posts: 98
Location: Maastricht, The Netherlands
Opus: V7
OS: Mac OS X 10.7.2 | Windows 8 Dev
System: i5 2.7 | 8G Ram | 1 T HD
Hi Jason,

Thank you for your repley.

If I use your code after
Code:
WHERE Omschrijving LIKE

I get an syntax error.

Hope you can solf this.

gr.

Ronnie


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 27th, 2005, 6:04 pm 
Offline

Joined: June 29th, 2005, 9:39 pm
Posts: 9
Ronnie,
You might need to check the dBase documentation and see if % will work in
a select statement. The only other thing that comes to mind right now is if the field your working with isn't defined as a string object you won't need the single quotes.
If you want to post the full sql statement I'll take a peek at it and check for any obvious syntax.

Jason


Top
 Profile  
 
 Post subject:
PostPosted: July 27th, 2005, 6:08 pm 
Offline

Joined: April 1st, 2005, 6:59 pm
Posts: 98
Location: Maastricht, The Netherlands
Opus: V7
OS: Mac OS X 10.7.2 | Windows 8 Dev
System: i5 2.7 | 8G Ram | 1 T HD
Jason,

Here is my code.

Code:
var db = new Database("FILEDSN=lasselsbergerVT.dsn");
var records = null;

//////////////////////////////////////////////////////////////////////////////
//
// 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 Artikel WHERE Omschrijving LIKE '"%zoekserie%"' ORDER BY Code;";
   // Debug.trace(sql+"\n");
   records = db.ExecuteSQL(sql);
   
   ShowRecords()
}
function ShowRecords()
{
   if (records == null) {
      return;  // need to call Search First to get records
   }
   
   var num_records = records.GetNumberOfRecords();
   if (num_records > Start_Record_Num) {
      // Jump to record that will be the first to be shown
      records.GetRecordAt(Start_Record_Num);
   }
   // Get first five records
   for (num=1; num<=5; num++)
   {
      var text_box = FindChild("Text "+num); // Get Text box called Text 1, Text 2 ...
      text_box.SetSelection(0, -1); // Select all text in box
      if (num <= (num_records - Start_Record_Num + 1)) {
         text_box.ReplaceSelection(records.Code);
      } else {
         text_box.ReplaceSelection("");   // Clear the text box
      }
      
      text_box = FindChild("Formaat "+num);
      text_box.SetSelection(0, -1);
      if (num <= (num_records - Start_Record_Num + 1)) {
         text_box.ReplaceSelection(records.formaatlengte); // Set the text in the text box
      } else {
         text_box.ReplaceSelection("");
            }
      
      text_box = FindChild("Formaatl "+num);
      text_box.SetSelection(0, -1);
      if (num <= (num_records - Start_Record_Num + 1)) {
         text_box.ReplaceSelection(records.formaatbreedte); // Set the text in the text box
      } else {
         text_box.ReplaceSelection("");
      }
      
      text_box = FindChild("Kleur "+num);
      text_box.SetSelection(0, -1);
      if (num <= (num_records - Start_Record_Num + 1)) {
         text_box.ReplaceSelection(records.Kleur); // Set the text in the text box
      } else {
         text_box.ReplaceSelection("");
      }
records.NextRecord();
   }
}

function Next()
{
   var num_records = records.GetNumberOfRecords();
   if (Start_Record_Num + 5 < num_records) { // Check there are 5 more records
      Start_Record_Num += 5;
   }
   
   ShowRecords();
}

function Previous()
{
   Start_Record_Num -= 5;      // Go Back 5 Records
   if (Start_Record_Num < 1) {   // Check not gone too far
      Start_Record_Num = 1;
   }
   
   ShowRecords();
}




In this script textfields are filled with textdata, is it possible to display images with the script above, I know it is possible with regular variable settings>

Code:
<SYSTEM_PUBLICATION_DIR>\artikelbestanden\tegels\<afbeeldingvt>.jpg



Ronnie


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 27th, 2005, 6:23 pm 
Offline

Joined: June 29th, 2005, 9:39 pm
Posts: 9
Ronnie,

Try it like this:

var sql = "SELECT * FROM Artikel WHERE Omschrijving LIKE '%" + zoekserie + "%' ORDER BY Code;";

The % needs to be within the double quotes and the string needs to be concated between the variable and the rest of the statement with +'s

Jason


Top
 Profile  
 
 Post subject:
PostPosted: July 27th, 2005, 7:00 pm 
Offline

Joined: April 1st, 2005, 6:59 pm
Posts: 98
Location: Maastricht, The Netherlands
Opus: V7
OS: Mac OS X 10.7.2 | Windows 8 Dev
System: i5 2.7 | 8G Ram | 1 T HD
Jason,

Thank you,

Could you please check my second questions. Personal I think that it can be changed with SetImage(), but I don't know how to set this!?


gr.

Ronnie


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 27th, 2005, 7:46 pm 
Offline

Joined: June 29th, 2005, 9:39 pm
Posts: 9
Ronnie,

You can set an image with a variable like this:
var Picture = "something.jpg"
var ImagePath = SYSTEM_PUBLICATION_DIR + "\\Lesson1\\" + Picture
myImage.SetImage(ImagePath)

Jason


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group