ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 AppendImage truncates FileName
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

880 Posts

Posted - Dec 09 2023 :  17:24:04  Show Profile  Reply
In the demo:
\Demos\Database\DBMultiBitmap_AllRecords

This method AppendImage truncates the filename in the database to 20 chracters:

procedure TMainForm.btnAppendClick(Sender: TObject);
begin
  if dlgOpenImage.Execute then
    fDBMultiBitmap.AppendImage( dlgOpenImage.Filename );
end;


It seems the filename field in the IEDemoDB.sqlite database is restricted to 20 characters.

How can I enlarge it?

PeterPanino

880 Posts

Posted - Dec 09 2023 :  18:05:54  Show Profile  Reply
A friend helped me to modify the database with a Python script:

# Step 1: Create a new table with the modified column length for Filename
cursor.execute("""
    CREATE TABLE IF NOT EXISTS NewImages (
        ID INTEGER,
        Filename varchar(255),
        Description memo,
        Image image,
        PRIMARY KEY(ID)
    );
""")

# Step 2: Copy data from the old table to the new table
cursor.execute("""
    INSERT INTO NewImages (ID, Filename, Description, Image)
    SELECT ID, Filename, Description, Image FROM Images;
""")

# Step 3: Drop the old table
cursor.execute("DROP TABLE Images;")

# Step 4: Rename the new table to the old table's name
cursor.execute("ALTER TABLE NewImages RENAME TO Images;")

# Commit the changes and close the connection
conn.commit()
conn.close()


Now, the file name field can hold up to 255 characters.
Go to Top of Page

PeterPanino

880 Posts

Posted - Dec 10 2023 :  03:23:58  Show Profile  Reply
The database provided by the ImageEn DBMultiBitmap_AllRecords demo (IEDemoDB.sqlite) also contains a DESCRIPTION (Memo) field:





I assume this field was intentionally created for ImageEn. Therefore, please provide an AppendImage method with an optional Description parameter for database purposes. Thank you!

Example: fDBMultiBitmap.AppendImage( dlgOpenImage.Filename, Description );
Go to Top of Page

xequte

38341 Posts

Posted - Dec 10 2023 :  17:26:07  Show Profile  Reply
Hi Peter

TIEDBMultiBitmap does not know the names of the field in your database (only the one you specify as containing the image). If you want an AppendImage() method that appends an image and then sets one of your fields, you should create a helper method.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: