1
Answer

retireve multiple images from database and show in view

i am trying to show an image in view. i am using mvc 5 now, below  is my view code and server side code. so please help me how i show a single image or multiple images from database,
view code,
 
@model NewAuthentication.ViewModel.PhotoViewModel
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>myprof</title>
</head>
<body>
<div>
<table>
<tbody>
<tr>
<td>
<img src="@Model.photo" />
</td>   </tr>
</tbody>
</table>
</div></body>
</html>
 
and server side code, 
 
i create a viewmodel which is shown below,
 
public class PhotoViewModel
{
public int id { get; set; }
public string photo { get; set; }
public string firstname { get; set; }
public string Gender { get; set; }
 
and action method  code is below,
 
public ActionResult myprof()
{
SqlConnection con = new SqlConnection("Data Source=JAGDISH;Database=Hmarasmaj;Integrated Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("Select photo from ParentImages where pid="+1+"",con);
DataTable dt = new DataTable();
da.Fill(dt);
int c = dt.Rows.Count;
PhotoViewModel p = new PhotoViewModel();
byte[] img =(byte[]) dt.Rows[0]["photo"];
p.photo = "data:image/png;base64," + Convert.ToBase64String(img);
return View(p);
}

Answers (1)

0
Photo of Abhimanyu K Vatsa
NA 50.9k 12.4m 14y
I think you are asking about Visual Studio 2010. so there are lots of articles which explains step by step procedure to develop crystal reports, 

please read right side [Our recommended articles]
0
Photo of Mahesh Chand
2 286.9k 123.8m 14y
I am not sure if VB 2010 comes with the ReportViewer or not. You probably have to use Visual Studio 2010. You do not need any Crystal or other products to build reports using ReportViewer. This control is a Microsoft control.