| | |
i want opposite of this
![]() |
•
•
Join Date: Aug 2009
Posts: 85
Reputation:
Solved Threads: 0
Hi here image is getting converted into binary and getting inserted into sqltable .
Now I want the opposite of it i mean i want to retrieve the binary
data and display it as image.
Now I want the opposite of it i mean i want to retrieve the binary
data and display it as image.
ASP.NET Syntax (Toggle Plain Text)
protected void btnupload_Click(object sender, EventArgs e) { // set temporary variable for database connection SqlConnection SqlCon = new SqlConnection("Data Source=localhost;Initial Catalog=ArjunPlastic;Uid=sa;Pwd=vagi0903"); SqlCon.Open(); string SQL = "INSERT INTO pictures (Filename,Picture) VALUES ('flower',@image)"; SqlCommand SqlComm = new SqlCommand(SQL,SqlCon); SqlParameter parimage= new SqlParameter("@image", SqlDbType.Image); // convert image file to byte array and pass to sql parameter value parimage.Value = FileToByteArray("C:\\Documents and Settings\\Administrator\\Desktop\\4014_thumb.jpg"); SqlComm.Parameters.Add(parimage); SqlComm.ExecuteNonQuery(); } public byte[] FileToByteArray(string FileName) { byte[] Buffer = null; // Open file for reading FileStream FileStream = new FileStream(FileName,FileMode.Open,FileAccess.Read); // attach filestream to binary reader BinaryReader BinaryReader = new BinaryReader(FileStream); // get total byte length of the file long TotalBytes = new FileInfo(FileName).Length; // read entire file into buffer Buffer = BinaryReader.ReadBytes((Int32)TotalBytes); // close file reader FileStream.Close(); FileStream.Dispose(); BinaryReader.Close(); return Buffer; }
Last edited by peter_budo; Aug 5th, 2009 at 2:15 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Please use code tags when posting code on daniweb:
[code=c#]
...code here...
[/code]
Next -- Please stop opening duplicate thread. I have already given you the answer to that in http://www.daniweb.com/forums/thread209172.html
For some reason you have in your head that I am not storing the image as binary on the SQL server which is not the case. Please try the code first.
[code=c#]
...code here...
[/code]
Next -- Please stop opening duplicate thread. I have already given you the answer to that in http://www.daniweb.com/forums/thread209172.html
For some reason you have in your head that I am not storing the image as binary on the SQL server which is not the case. Please try the code first.
Thread closed, double posting is not welcome.
Stick to original post.
Stick to original post.
Last edited by peter_budo; Aug 5th, 2009 at 2:17 pm.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Sort in opposite direction (Python)
- Any Anime fans in here? (Geeks' Lounge)
- What's better? Windows 2000 Server or Linux Server? (Windows Servers and IIS)
- Opposite of most (Social Media and Online Communities)
- article on affiliate programs (Advertising Sales Strategies)
- Solar Storm (Troubleshooting Dead Machines)
- question on cooling (Cases, Fans and Power Supplies)
- video card temps (Monitors, Displays and Video Cards)
- Automating a copy/move (Windows NT / 2000 / XP)
Other Threads in the ASP.NET Forum
- Previous Thread: Urgent Answer needed
- Next Thread: Popup window with zoomed image
Views: 295 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 2005 ajax ajax-doc application asp asp.net asp.net-mvc asp.net_hw_sw authentication authorization beginner browser button c# captcha chat checkbox click compatible connectionstring control crystalreport dataaccesslayer database datagridview datalist delete deployment development dgv dropdown dynamically edit editor encryption expose external feedback fill flash folder form forms gridview homeedition identity iframe iis impersonation index javascript list login maps masterpage membership mysql order panelmasterpagebuttoncontrols parent problem profile purchase ratings read redirect refer request.form search security server session sessionvariables sharepoint silverlight sql sql-server sqlexpress-attach subdomain theft tracking translate-web-pages update user validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webdevelopemnt webservice website windows-auth xml





