Home > Net >  An error has occurred winform upload photos to the database
An error has occurred winform upload photos to the database

Time:09-22

This is the database
Figure 1 is a images have a mistake?
Figure 2 is the name and photo are invalid? (FIG. 3)

CodePudding user response:

Error is obvious, the data are not compatible, is where the red box you add parameters and the second assignment, image type and the inside of the database field types, generally best picture don't save to the database, or out and transformation, and your picture database field length is only 20, most of the time the image into a byte occurs not only 20, if can save, come and remove image data is incomplete, suggest you upload pictures to a path on the server, database photo fields to store image upload path + name,

CodePudding user response:

reference 1/f, what all don't understand so improper program apes response:
error obviously, the data are not compatible, is where the red box you add parameters and the second assignment, image type and the inside of the database field types, generally best picture don't save to the database, or out and transformation, and your picture database field length is only 20, most of the time the image is converted into byte occurs not only 20, if can save, come and remove image data is incomplete, it is recommended that you upload pictures to a path on the server, database photo fields to store image upload path + name,

Converted to binary images, can be in the database, but the data in the database type is varchar rather than image

CodePudding user response:

refer to the second floor three-year-old son reply:
Quote: reference 1/f, what all don't understand so improper program apes response:
error message is very obvious, the data are not compatible, is where the red box you add parameters and the second assignment, image type and the inside of the database field types, generally best picture don't save to the database, or out and transformation, and your picture database field length is only 20, most of the time the image is converted into byte occurs not only 20, if can save, come and remove image data is incomplete, suggest you upload pictures to a path on the server, database photo fields to store image upload path + name,

Converted to binary images, can be placed within the database, but the data in the database type is varchar rather than image

Is the transformed data compatibility problems, can in the database is now? So have you considered, when your photos into byte after more than 20 bytes? Even if change the length of the string is set to one hundred bytes, there will be greater than one hundred bytes of images, so generally are kept in the database table image path, rather than directly to store image data

CodePudding user response:


It has made a create binary stream object and is received byte array such a code,

CodePudding user response:

Images can be stored in the fixed path, the image path is stored in the database,
  •  Tags:  
  • C#
  • Related