Looping over a directory and reading Jpegs into a database -- Realbasic 4.5 
Author Message
 Looping over a directory and reading Jpegs into a database -- Realbasic 4.5

Software Version RB Commercial Pro 4.5 OS X

Here is code that works for populating a local realdatabase from a Postgres
database. I want the file that is pointed to in the postgres database to be
read from a directory and put into a jpeg field in the RealDB.

It works except that it only does the first one and no others....

Am I missing something? I have tried the files on the local machine and the
server with no success.

Please Help

  dim db, ldb As database
  dim SQLstatement, imagelisting As string
  dim rs As recordSet
  dim image_f,f As folderItem
  dim rec As databaserecord
  dim pathname As string
  dim p_buffer As picture

//   Local database file
  f = getfolderItem("SCS_database_2")

  if not f.exists then
    beep
    msgBox "The local database file is missing."
  else
    ldb = openREALDatabase(f)
    if ldb =nil then
      beep
      msgbox "The local Database could not be opened"
    else

      //pathname = "NETWORK PATH:photos:111111:"
      pathname = "Macintosh HD:111111:"
      db=
openPostgreSQLDatabase("SERVERID",5432,"DBNAME","USER","PASSWORD")
      if db = Nil then
        beep
        msgBox "Database connection to synchroCom Failed"
        quit
      else
        // Grab only a few
        SQLstatement ="select imageid,companyid , companyimageid,
                                    imagename, description from images where
active = 1 and
                                    companyid = 111111 and imageid between
174 and 190"
        rs = db.SQLSelect(SQLstatement)

        while not rs.EOF
            // Build the path to the file
          imagelisting = imagelisting + pathname +
rs.field("companyid").StringValue +"_" + rs.field("imageid").StringValue +
"_m.jpg"
          image_f = getfolderItem(imagelisting)
          if image_f.exists then
            //msgbox "it exists"

            //display_canvas.backdrop = image_f.openaspicture

            // window1.Refresh
            // msgbox "canvas updated"
            p_buffer = newpicture(500,500,32)
            p_buffer.graphics.Drawpicture image_f.openaspicture,0,0

            display_canvas.graphics.drawPicture p_buffer,0,0
            rec = new databaserecord
            rec.jPEGColumn("Image") = image_f.openaspicture

            rec.integerColumn("id") = rs.field("imageid").integerValue
            rec.column("sku") = rs.field("companyimageid").getstring
            rec.column("title") = rs.field("imagename").getstring
            rec.column("description") = rs.field("description").getstring
            rec.column("AGR_Bond_number") = rs.field("imageid").getstring
            rec.column("AGR_importer_number") =
rs.field("imageid").getstring
            rec.column("AGR_Reg_number") = rs.field("imageid").getstring
            rec.column("AGR_Trade_mark") = rs.field("imageid").getstring

            ldb.insertRecord("items", rec)
            if ldb.error then
              beep
              //msgBox ldb.errormessage
            end if

          end if
          image_f = nil
          rs.movenext
        wend

        //msgBox imagelisting
      end if
    end if
    db.close
    ldb.close
  end if



Mon, 31 Jan 2005 01:48:50 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. How do you use jpegs in a realbasic database on the PC

2. RealBasic 4.5 ???

3. REALbasic 4.5?

4. 4.5 Directory Selection Dialog

5. Warp 4.5 and loop

6. Matching Data Types between RealBasic and the RealBasic Database

7. Works 4.5 database.

8. HELP ON DIRECTORY READS INTO DATABASE

9. Can I read files made in version 4.5 with 4.1 Reader

10. Store JPEGs in RB Database structure

11. RealBasic Database and Export

12. RealBasic Database Date format

 

 
Powered by phpBB® Forum Software