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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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
 
what do you mean by .Net Framework Guru-Tech11
In vb.net how to connect crystal report?  1
What is MSIL  4
Disadvantages of vb ? Digital-GlobalSoft4
what r the properties should be given to set method? PSI-Data-Systems2
how can we assigns items on listbox so that it will show rowwise please write the code for it.  3
hello! I am developing software in vb6 and vb.net separately which i need to generate barcodes e.g i have a string "182346-u",so the problem is that how to generate barcode from this type of string can any body help me please thanks regard !  2
what is vb.net?  9
Regarding Types of compatability in VB and their usage ? Satyam1
What is intermediate language in .NET ? Digital-GlobalSoft13
how to create views in sql with syntax and example  5
What is the Difference between CLR & CTS?  2
in my windows application i have to show excelwork sheetwhich is stored in the local system can any one tell me the code?  1
what are the advantages and diadvantages of active reports over crystal reports ? IBM1
What are the similarities between class and structure? Ksb5
concept of object oriented programming Patni5
hi dear ! thank u for replying to my question regarding adding third party software in vb.net .My next question is that i haven created Data base in SQL server 2000 for Library and has connected that with VB and VB.net separately but it only works on single computer and when i takes my software to another computer on same Network it does not work . Can any body help me what i do to solve. Regards!  1
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
In Datagrid after adding row, how you will assign the value for each cell to currently added new row?  1
how to create crystal reports in asp.net & vb.net with syntax  1
 
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