| | |
retieve image from database
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2006
Posts: 32
Reputation:
Solved Threads: 1
I did this a few months ago but here is the code I used.
And then you would simply put viewimage.aspx?id=1234 as the src in your img tag and it would load the required image from the database.
This probably is not the best or most flexible code buit it does work.
If you have an specific questions just shoot.
ASP.NET Syntax (Toggle Plain Text)
private void Page_Load(object sender, System.EventArgs e) { dbConn = new System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings["connString"]); string id = Request.QueryString["id"]; string sCmd = "SELECT Photo FROM t_Student_Photos WHERE Photo_Id =" + id; cmd = new System.Data.SqlClient.SqlCommand(sCmd, dbConn); dbConn.Open(); dbReader = cmd.ExecuteReader(); if( dbReader.Read()) { //Reponse.Content type would have to change depending on the type of image Response.ContentType = "image\\jpeg"; Response.BinaryWrite((byte[])dbReader["Photo"]); } //Close Connection dbConn.Close(); }
And then you would simply put viewimage.aspx?id=1234 as the src in your img tag and it would load the required image from the database.
This probably is not the best or most flexible code buit it does work.
If you have an specific questions just shoot.
![]() |
Similar Threads
- How insert image into mysql database and retrieve (PHP)
- retrieving image from mysql database using php (PHP)
- Display image from a database get me ascii codes (ASP)
Other Threads in the ASP.NET Forum
- Previous Thread: can any body help me !!
- Next Thread: Help Writng and reading cookie
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv form forms grid gridview gudi homeedition hosting iis image javascript jquery list menu mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases rotatepage search security select serializesmo.table sessionvariables silverlight smoobjects sql ssl tracking treeview typeof validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xml xsl





