ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories >> Software >> Microsoft-Related >> VB.NET
 
 
 
Question
hello 
dear friends my problem is that i want to save images that 
is pictures in SQL server using vb.net can any body help me 
to do so please 
 Question Submitted By :: Ijaz_sh
I also faced this Question!!     Rank Answer Posted By  
 
Answer
step1) place one fileUpload control from tool box
step2) in it's Button click event
    If FileUpload1.PostedFile Is Nothing  Then
                Response.Write("no file posted")
                
            Else
               Here Convert that image as byte and pass it
to function.
                Dim con As SqlConnection
                Dim cmd As SqlCommand
                Dim ds As New DataSet

                con = New
SqlConnection(ConfigurationManager.AppSettings("connectionString"))
                cmd = New SqlCommand("insert into tablename
values(@image_in), con)
 Dim imageByte(FileUpload1.PostedFile.InputStream.Length) As
Byte
               
FileUpload1.PostedFile.InputStream.Read(imageByte, 0,
imageByte.Length)
                cmd.Parameters.AddWithValue("@image_in",
imageByte)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
               
                Response.Write("file is inserted")
            End If
 
0
Govind
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com