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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  VB.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
How to store jpeg / gif / bmp image in database and how to
retrieve them? The most stressful condition is database is
distributed and stored images can be retrive  from any
computer in network and any one can store images from other
computer!! plss help its urgent.......RAHUL RATHOD
 Question Submitted By :: Rahulrathod
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to store jpeg / gif / bmp image in database and how to retrieve them? The most stressful condition is database is distributed and stored images can be retrive from any computer in network and any one can store images from other computer!! plss help its urgent.......RAHUL RATHOD
Answer
# 1
Hi Rahul,
if you want to save image in SQL Server DataBase,
first we have to convert that image into bytes(BCoz SQL 
Server support byte format).
using system.io.iostream we can convert image into stream 
of bytes.

For example :

stfFilename is path that contain your image.

 Public Shared Function LoadImage(ByVal stfFilename As 
String) As System.Drawing.Image

Dim oStream As System.IO.Stream
Dim oAssembly As System.Reflection.Assembly
oAssembly = System.Reflection.Assembly.GetEntryAssembly
oStream = oAssembly.GetManifestResourceStream(stfFilename)
Return System.Drawing.Image.FromStream(oStream)
End Function

for retrieving image from DB just reverse concept.

 
Is This Answer Correct ?    2 Yes 2 No
Raj
 
  Re: How to store jpeg / gif / bmp image in database and how to retrieve them? The most stressful condition is database is distributed and stored images can be retrive from any computer in network and any one can store images from other computer!! plss help its urgent.......RAHUL RATHOD
Answer
# 2
For Save Images:

 Private Sub Save()
        Dim strConn, strQuery As String
        Dim cmd As SqlCommand
        Dim img As Image
        Dim imagedata As Byte()
        Dim imgFormat As Imaging.ImageFormat
        Dim myParameter As SqlParameter
        Try
            img = Image.FromFile(Me.txtImage.Text)
            imgFormat = img.RawFormat

            imagedata = ConvertImageToByteArray(img, imgFormat)

            strQuery = "Insert into TBL_STUDENT
(STUD_NAME,SUBJECT,NUMBER,IMAGES) values ('" & txtName.Text
& "','" & txtSubject.Text & "'," & txtNumber.Text & ",@Image)"
            strConn = //Your Connection String
            conn = New SqlConnection(strConn)
            cmd = New SqlCommand(strQuery, conn)

            myParameter = New SqlParameter("@Image",
SqlDbType.Image, imagedata.Length)
            myParameter.Value = imagedata
            cmd.Parameters.Add(myParameter)


            conn.Open()
            cmd.ExecuteNonQuery()
 
            MsgBox("Saved Successfully", MsgBoxStyle.OkOnly)
        Catch ex As Exception

        End Try
    End Sub

  Private Shared Function ConvertImageToByteArray(ByVal
imageToConvert As System.Drawing.Image, ByVal formatOfImage
As Imaging.ImageFormat) As Byte()
        Dim Ret As Byte()

        Try
            Using ms As New MemoryStream()
                imageToConvert.Save(ms, formatOfImage)
                Ret = ms.ToArray()
            End Using
        Catch generatedExceptionName As Exception
            Throw
        End Try

        Return Ret
    End Function

For Retrieve:

 Private Sub RetrieveImages()
        Dim strConn As String
        Dim cmd As SqlCommand
        Dim da As SqlDataAdapter

        Try
            strConn = //Connection string
            conn = New SqlConnection(strConn)
            cmd = New SqlCommand("Select * from
TBL_STUDENT", conn)
            da = New SqlDataAdapter(cmd)
            ds = New DataSet
            da.Fill(ds)
        Catch ex As Exception

        End Try
    End Sub
 
Is This Answer Correct ?    4 Yes 1 No
Debolina
 
 
 

 
 
 
Other VB.NET Interview Questions
 
  Question Asked @ Answers
 
how to send data to exe file? my code has a button when i press it, an exe file will open. how can i send data as input to the exe file?  2
what do you mean by .Net Framework Guru-Tech11
How to store jpeg / gif / bmp image in database and how to retrieve them? The most stressful condition is database is distributed and stored images can be retrive from any computer in network and any one can store images from other computer!! plss help its urgent.......RAHUL RATHOD  2
How does you get record no from 5 to 15 from a dataset of 100 records? ABC2
Regarding Types of compatability in VB and their usage ? Satyam1
what are the difference between An input box and Message box ..?  3
diff b/w windows and console application?  2
I want to reduce my CPU Usage when I am querying the Database for records. Now my Winform App(in VB.Net) suddenly Jumps to 100% CPU Usage when i query for records from sql server database. I want this Usage to be less. Any help is appreciated  2
what is the dif b/w panel and groupbox. Ksb3
when we will use console ?  3
What is the difference b/w Readonly Variable and Constant Variable? Sonata5
What is DLL hell?  2
what are the advantage in vb.net and different between vb and vb.net TCS4
What is the Difference between Dataset and Datareader?  4
Hi I am planning to take interview in VB.net,can any one share your interview Questions for a Entry-level job. Regards Lina  3
What does VS.NET contains ? Infosys3
What is an indexed property?  1
What is MSIL. HDFC3
how to connect crystal report with vb.net ? Patni6
wht is the use of console application?  3
 
For more VB.NET Interview Questions Click Here 
 
 
 
 
 
   
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