Update image using Datalist control and Sqldatasource

peter liles 556 Reputation points

In the UpdateCommand event i am trying to update a image in Datalist edittemplate. The problem is bmpBytes is a byte array and sql updateparameter declaration<asp:Parameter Name="Data" DbType="Binary" /> will not accept it in this format only string. My database type is set to Image.
The system responds with cannot convert from string to image.

VanImagesSqlDataSource.UpdateParameters("Data").DefaultValue = bmpBytes

A set of technologies in the .NET Framework for building web applications and XML web services.
3,234 questions
0 comments No comments
{count} votes

Accepted answer
  1. QiYou-MSFT 4,306 Reputation points Microsoft Vendor

    Hi @peter liles ,
    You can try setting parameters in an update event.
    Maybe you can provide detailed error messages and codes.

    private void sqlDataSource_Updating(object sender, SqlDataSourceCommandEventArgs e)  
        e.Command.Parameters["File"].Value = bytes;  

    Setting the update parameter type as Object

    <asp:Parameter Name="File" Type="Object" />  

    Best regards,

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful