-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: saileshsaha
Message 2 in Discussion

To retreive images from SQL Server, you can use the following code snippet:    
<%@ Page Language="vb" %><o:p></o:p> 
<%@ Import Namespace="System.Data" %><o:p></o:p> 
<%@ Import Namespace="System.Data.SqlClient" %><o:p></o:p> 
<HTML><o:p></o:p> 
  <HEAD><o:p></o:p> 
    <title>Retrieving Image from the Sql Server</title><o:p></o:p> 
    <o:p></o:p> 
    <script runat=server><o:p></o:p> 
                        Public Sub Page_Load(sender As Object, e As 
EventArgs)<o:p></o:p> 
                                    ' Create Instance of Connection and Command 
Object<o:p></o:p> 
                                    Dim myConnection As New 
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))<o:p></o:p> 
                                    Dim myCommand As New SqlCommand("Select * from 
Person", myConnection)<o:p></o:p> 
 <o:p></o:p> 
                                    Try<o:p></o:p> 
                                                myConnection.Open()<o:p></o:p> 
                                                Dim myDataReader as SqlDataReader 
<o:p></o:p> 
                                                myDataReader = 
myCommand.ExecuteReader(CommandBehavior.CloseConnection)<o:p></o:p> 
                                                <o:p></o:p> 
                                                Do While 
(myDataReader.Read())<o:p></o:p> 
                                                            Response.ContentType = 
myDataReader.Item("PersonImageType")<o:p></o:p> 
                                                            
Response.BinaryWrite(myDataReader.Item("PersonImage"))<o:p></o:p> 
                                                Loop<o:p></o:p> 
                                                <o:p></o:p> 
                                                myConnection.Close()<o:p></o:p> 
                                                Response.Write("Person info 
successfully retrieved!")<o:p></o:p> 
                                    Catch SQLexc As SqlException<o:p></o:p> 
                                                Response.Write("Read Failed : " & 
SQLexc.ToString())<o:p></o:p> 
                                    End Try<o:p></o:p> 
                        End Sub    <o:p></o:p> 
    <o:p></o:p> 
    </script><o:p></o:p> 
    <o:p></o:p> 
  </HEAD><o:p></o:p> 
  <body style="font: 10pt verdana"><o:p></o:p> 
  </body><o:p></o:p> 
</HTML> 
  
Hope this solves your problem.<o:p></o:p>

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to