473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to display image from database to datagridview

Hello,
I have books_table in the database. which contain Id, title ,subtitle image & others.
I have inserted the image in the string form in the database.
Now i want to display all records in the Datagrid view in windows Form.

I'm able to display all fields but unable to display the image of a book in the datagrid view.

In database Image is url stored as string

I put all the records in the genric list:

Expand|Select|Wrap|Line Numbers
  1. public List<Book> GetBooks()
  2.         {
  3.             var books = new List<Book>();
  4.             using (DbConnection connection = new SqlConnection(connectionString))
  5.             using (DbCommand command = connection.CreateCommand())
  6.             {
  7.                 command.CommandText = "SELECT * FROM Book3";
  8.                 connection.Open();
  9.                 using (DbDataReader reader = command.ExecuteReader())
  10.                 {
  11.                     while (reader.Read())
  12.                     {
  13.                         books.Add(new Book()
  14.                         {
  15.                             Id = (int)reader["Id"],
  16.                             Title = (string)reader["Title"],
  17.                             Subtitle = (string)reader["Subtitle"],
  18.                             Isbn = (string)reader["Isbn"],
  19.                             Price = Convert.ToString(reader["Price"]),
  20.                             Image = (string)reader["Image"],
  21.                             Url = (string)reader["Url"]
  22.                         });
  23.                     }
  24.                 }
  25.             }
  26.             return books;
  27.         }
Jan 2 '19 #1
0 2047

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
3
by: harish | last post by:
Hi friends I am facing problem as follow I can't display image from SQL Database to Picture box Control. Here are the codes that I am writing Dim arrPicture() As Byte = _
2
by: RedSouljaz | last post by:
Hi, How to display image that was saved in database ms sql server 2000 into picture box. The field type that I use in database is Images I can save to database but cannot show from database. ...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
7
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed...
7
by: alexseow | last post by:
Query.asp <%@ LANGUAGE="VBSCRIPT" %> <!-- #include file="../../includes/dbconn.asp"--> <% dim MyRs, sqlstr, MyConn Response.Expires = 0 Response.Buffer = TRUE Response.Clear
4
Prathap
by: Prathap | last post by:
I am using vb.net.I want to display image in datagridview or picture box from sqlserver .Could someone please help me.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.