简体   繁体   中英

How to display images from mysql database using asp.net

I am using MySQL, I stored my images as varchar in the database, how can I display those images? Any help is appreciated.

My code:

public static DataTable GetAllMydetails()
{
    string connString = "Server=localhost;database=test;uid=root;";
    string query = "SELECT `Mydetails`.`Image`";

    MySqlDataAdapter ma = new MySqlDataAdapter(query, connString);

    DataSet DS = new DataSet();
    ma.Fill(DS);

    return DS.Tables[0];    
}

protected void Page_Load(object sender, EventArgs e)
{
   // I want to display image here on page load...//
}

How could you store that image in varchar? Means you stored image name or converted into bytes and then stored?

Because we can't directly store image without using image data type.

So can you please be brief?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM