Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EF Core 3.1 Beta OracleException: ORA-01460

user606112Jul 12 2020 — edited Jul 16 2020

Adding an image and saving the context ORA-01460 occurs.

DB-Set in Model:

public class Picture

{

    public int PictureID { get; set; }

    public byte\[\] Bild { get; set; }

    public DateTime Ludsys { get; set; }

    public int OrderDetailID { get; set; }

    public OrderDetail OrderDetail { get; set; } // Navigationseigenschaft

} // Picture

Table in DB:

Table in ORA DB.JPG

If I load the image and save it with SQL-Developer it can be read and displayed in the application.

Create the picture:

...

picture = new Picture

{

 Bild = null,

 Ludsys = DateTime.Now,

 OrderDetail = orderdetail

}; // picture

imgBild.DataContext = picture;

imgBild.Source = FileToBitmapImage(dlg.FileName); // Bild aus Filesystem laden und anzeigen

context.Pictures.Add(picture);

pictures.Add(picture);

ind = pictures.Count - 1; // Index für den neuen Datensatz ist pictures.Count - 1

...

    private BitmapImage FileToBitmapImage(string source)

    {

        try

        {

            if (source == string.Empty) { return null; }

            BitmapImage bitmapimage = new BitmapImage();

            using FileStream filestream = File.Open(source, FileMode.Open);

            bitmapimage.BeginInit();

            bitmapimage.CacheOption = BitmapCacheOption.OnLoad;

            bitmapimage.StreamSource = filestream;

            bitmapimage.EndInit();

            return bitmapimage;

        } // try

        catch (Exception ex)

        {

            MessageBox.Show(ex.Message, "Nachricht", MessageBoxButton.OK, MessageBoxImage.Error);

            return null;

        } // catch

    } // FileToBitmapImage

ImageConverter:

     public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

    {

        try

        {

            if (value == null) { return null; }

            byte\[\] byteArray = (byte\[\])value;

            using MemoryStream memorystream = new MemoryStream(byteArray);

            BitmapImage bitmapimage = new BitmapImage();

            bitmapimage.BeginInit();

            bitmapimage.CacheOption = BitmapCacheOption.OnLoad;

            bitmapimage.StreamSource = memorystream;

            bitmapimage.EndInit();

            return bitmapimage;

        } // try

        catch (Exception)

        {

            return null;

        } // catch

    } // Convert

    // ConvertBack (Ziel -> Quelle)

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

    {

        try

        {

            if (value == null) { return null; }

            ImageSource imagesource = (ImageSource)value;

            BitmapSource bitmapsource = imagesource as BitmapSource;

            BitmapEncoder encoder = new JpegBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(bitmapsource));

            using MemoryStream ms = new MemoryStream();

            encoder.Save(ms);

            byte\[\] bytearray = ms.ToArray();

            return bytearray;

        } // try

        catch (Exception)

        {

            return null;

        } // catch

    } // ConvertBack
This post has been answered by Alex Keh-Oracle on Jul 14 2020
Jump to Answer

Comments

Post Details

Added on Jul 12 2020
8 comments
741 views