Hello all Experts,

I have following Code to get Image from dataBase and Show it in the Gridview Control on my web page but I am succeded to get data but when I bound the DataSet with GridView it doesnot show me Image.

You can View error on Attached Image.


Can any one Solve my problem.

Thanks in Advance.

Public Cmd As New SqlClient.SqlCommand
  Public SQLCon As New SqlClient.SqlConnection(Con)
  Public ds As New DataSet
  Public myAdapter As New SqlDataAdapter
  Public MyActiveFormName As String
  Public Qry As String
  Public EmptyTable As Boolean



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Sql_Procedures.Fill_DataSetWithOutArg("Sel_MovMaster", "Tbl_SelMovMaster4MainPage")

   dg_Main4Master.DataSource = Sql_Procedures.ds.Tables("Tbl_SelMovMaster4MainPage")
    dg_Main4Master.DataBind()

End Sub


  Public Sub Fill_DataSetWithOutArg(ByVal SPName As String, ByVal TableName As String)
    Try
      myAdapter = New SqlDataAdapter(SPName, SQLCon)
      myAdapter.Fill(ds, TableName)
      ds.Tables(TableName).Clear()
      myAdapter.Fill(ds, TableName)
      If ds.Tables(TableName).Rows.Count = 0 Then
        EmptyTable = True
      Else
        EmptyTable = False
      End If
    Catch ex As Exception
      MsgBox(ex.Message)
    End Try
  End Sub

I don't recommend trying to store images in a database, try storing the path to the image in the database then load the image from the stored path.

You can store that image path and than you can call that path into another gridview, and image will be display after calling that path:Image1.ImageUrl = GridView1.SelectedRow.Cells[13].Text;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.