How to show image from ms access to gridview
-
my database Ms Access has 3 fields as folllows; id- number imageName- text imageURL- text ................................................... I have a fileupload tool and a button names btnUpload which helps to upload images to a folder and that path gets saved in database field names imageURL. ......................................................... Inherits System.Web.UI.Page Dim constr As String = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=D:\imgupload\db1.mdb;Persist Security Info=False;" Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click If FileUpload1.HasFile Then FileUpload1.SaveAs(IO.Path.Combine(Server.MapPath("Image"), FileUpload1.FileName)) fnSaveFile(IO.Path.GetFileName(FileUpload1.FileName), IO.Path.Combine(Server.MapPath("Image"), FileUpload1.FileName)) End If End Sub Public Sub fnSaveFile(ByVal FileName As String, ByVal FileURL As String) Dim cmd As New OleDb.OleDbCommand Dim con As New OleDb.OleDbConnection(constr) Try Dim strSql As String = "insert into tbl_Image(ImageName,ImageURL) values('" & FileName & "','" & FileURL & "')" '------------" con.Open() cmd.Connection = con cmd.CommandText = strSql cmd.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.Message) Finally cmd.Dispose() con.Dispose() End Try End Sub ................................................................ my image uploading is working well. cud anyone sugesst me a way to add a gridview and show the image other than showing the path of the image.
-
my database Ms Access has 3 fields as folllows; id- number imageName- text imageURL- text ................................................... I have a fileupload tool and a button names btnUpload which helps to upload images to a folder and that path gets saved in database field names imageURL. ......................................................... Inherits System.Web.UI.Page Dim constr As String = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=D:\imgupload\db1.mdb;Persist Security Info=False;" Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click If FileUpload1.HasFile Then FileUpload1.SaveAs(IO.Path.Combine(Server.MapPath("Image"), FileUpload1.FileName)) fnSaveFile(IO.Path.GetFileName(FileUpload1.FileName), IO.Path.Combine(Server.MapPath("Image"), FileUpload1.FileName)) End If End Sub Public Sub fnSaveFile(ByVal FileName As String, ByVal FileURL As String) Dim cmd As New OleDb.OleDbCommand Dim con As New OleDb.OleDbConnection(constr) Try Dim strSql As String = "insert into tbl_Image(ImageName,ImageURL) values('" & FileName & "','" & FileURL & "')" '------------" con.Open() cmd.Connection = con cmd.CommandText = strSql cmd.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.Message) Finally cmd.Dispose() con.Dispose() End Try End Sub ................................................................ my image uploading is working well. cud anyone sugesst me a way to add a gridview and show the image other than showing the path of the image.
Did you gone through the all the reply that was provided to you in your last post?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net
-
Did you gone through the all the reply that was provided to you in your last post?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net
-
ya but I didnt understand or get any idea to change those to my requirement. plz help me
Pratheepa wrote:
ya but I didnt understand or get any idea to change those to my requirement. plz help me
Well, posting the same question again, will get you the same answers. The problem is that you're not capable of doing this task. If this is homework, talk to your teacher. If this is paid work, tell your client that you are a fraud now, and save you and them further time and hassle. We answered you. If you can't understand it, that's not our fault.
Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
-
ya but I didnt understand or get any idea to change those to my requirement. plz help me
Pratheepa wrote:
ya but I didnt understand or get any idea to change those to my requirement.
:(
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net
-
my database Ms Access has 3 fields as folllows; id- number imageName- text imageURL- text ................................................... I have a fileupload tool and a button names btnUpload which helps to upload images to a folder and that path gets saved in database field names imageURL. ......................................................... Inherits System.Web.UI.Page Dim constr As String = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=D:\imgupload\db1.mdb;Persist Security Info=False;" Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click If FileUpload1.HasFile Then FileUpload1.SaveAs(IO.Path.Combine(Server.MapPath("Image"), FileUpload1.FileName)) fnSaveFile(IO.Path.GetFileName(FileUpload1.FileName), IO.Path.Combine(Server.MapPath("Image"), FileUpload1.FileName)) End If End Sub Public Sub fnSaveFile(ByVal FileName As String, ByVal FileURL As String) Dim cmd As New OleDb.OleDbCommand Dim con As New OleDb.OleDbConnection(constr) Try Dim strSql As String = "insert into tbl_Image(ImageName,ImageURL) values('" & FileName & "','" & FileURL & "')" '------------" con.Open() cmd.Connection = con cmd.CommandText = strSql cmd.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.Message) Finally cmd.Dispose() con.Dispose() End Try End Sub ................................................................ my image uploading is working well. cud anyone sugesst me a way to add a gridview and show the image other than showing the path of the image.
If im understanding right then just put this in ur gridview on ur aspx page: <img src='<%# DataBinder.Eval(Container.DataItem, "imageURL") %>' alt='<%# DataBinder.Eval(Container.DataItem, "imageURL") %>' />
-
If im understanding right then just put this in ur gridview on ur aspx page: <img src='<%# DataBinder.Eval(Container.DataItem, "imageURL") %>' alt='<%# DataBinder.Eval(Container.DataItem, "imageURL") %>' />