Hi Dipak,
Just a thought, Try if you have any problem on connecting to
the database
server from production instance, as it working on
development instance even
remotely, Just have a look if any issue with connection from
production
instance.
*Regards,
Rafeeq
Keralam.*
On Tue, Apr 29, 2008 at 5:57 PM, dipak mishra
<mishradipak gmail.com> wrote:
> Dear Tim, Rafeeq,
> I tried the code but again its not showing Images in
Grid View.
> I dont know wats the prob with it.
> It Shows images on my development machine but not on
system.
> My payment is stuck bcos of this error.Since on
developments machine it
> works well .... while on client side it sometimes
stops showing the
> image.Also same data base works well on our system.
>
> Need Help.Dont know wat to do..since no error on
develpmnt system.
>
> Regards
>
>
>
> On Wed, Apr 23, 2008 at 7:27 PM, Tim Curtin
<tjc_tek hotmail.com> wrote:
>
> > 1. Maybe you're supressing an exception. write it
out to a label
> > control.
> > 2. try setting the response.contenttype before you
response.binarywrite
> > the image bits.
> > *Do While** (rdimg.Read()) *
> > * Response.ClearHeaders()*
> > * Response.ClearContent()*
> > * Response.ContentType = "image/jpg"*
> >
Response.BinaryWrite(rdimg.Item("sampimg"))
> >
> > Loop
> >
> > Incidently, you should add a 'Finally' where you
close the connection.
> > Finally always runs regardless of an exception
> >
> > sub page_load(...)
> > Me.lblMessage.Text = ""
> > end sub
> >
> > function theFunction
> >
> >
> > dim con as new SqlConnection()
> > Try
> > con.connectionstring =
> >
ConfigurationManager.ConnectionStrings("connectionstrin
g").connectionstring
> > .......
> >
> > Catch ex As Exception
> > Me.lblMessage.Text = ex.Message 'View an
exception
> > Finally
> > If con.State <>
ConnectionState.Closed() Then con.Close()
> > End Try
> >
> >
> > Tim
> >
> > ------------------------------
> > Date: Wed, 23 Apr 2008 10:36:49 +0530
> >
> > From: mishradipak gmail.com
> > To: aspnet-databases aspadvice.com
> > Subject: [aspnet-databases] RE: Error displaying
images in gridview
> >
> > Dear Tim
> > here is the code............ for grid
view...............SampImg is the
> > name of the column to display image which has been
converted to templte
> > column ..........formaturl is the function used to
pass the sno which is
> > identity and primary key.
> >
> > <asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False"
> > CellPadding="4"
> > DataKeyNames="snoart"
DataSourceID="SqlDataSource4"
ForeColor="#333333"
> > GridLines="None"
AllowPaging="True"
AllowSorting="True">
> > <FooterStyle BackColor="#5D7B9D"
Font-Bold="True" ForeColor="White"
/>
> > <Columns>
> > <asp:CommandField
ShowSelectButton="True" />
> > <asp:BoundField DataField="snoart"
HeaderText="SNoArt" InsertVisible
> > ="False" ReadOnly="True"
> > SortExpression="snoart" />
> > <asp:BoundField DataField="sampname"
HeaderText="SampName"
> > SortExpression="sampname" />
> > <asp:BoundField DataField="artdesign"
HeaderText="ArtDesign"
> > SortExpression="artdesign" />
> > <asp:TemplateField
HeaderText="SampImg"
SortExpression="sampimg">
> > <EditItemTemplate>
> > <asp:TextBox ID="TextBox1"
runat="server" Text='<%#
Bind("sampimg") %>
> > '></asp:TextBox>
> > </EditItemTemplate>
> > <ItemTemplate>
> > <asp:Image ID="Image1"
width="75" Height="75"
runat="server" ImageUrl='<%#
> >
formaturl(databinder.Eval(container.dataitem,("snoart&q
uot;))) %>' />
> > </ItemTemplate>
> > </asp:TemplateField>
> > </Columns>
> > <RowStyle BackColor="#F7F6F3"
ForeColor="#333333" />
> > <EditRowStyle BackColor="#999999"
/>
> > <SelectedRowStyle BackColor="#E2DED6"
Font-Bold="True" ForeColor
> > ="#333333" />
> > <PagerStyle BackColor="#284775"
ForeColor="White" HorizontalAlign
> > ="Center" />
> > <HeaderStyle BackColor="#5D7B9D"
Font-Bold="True" ForeColor="White"
/>
> > <AlternatingRowStyle
BackColor="White" ForeColor="#284775"
/>
> > </asp:GridView>
> >
> >
> >
> >
> > then there is this format url function in code
behind page:--
> >
> >
> > *Function formaturl(ByVal strarguement) As
String*
> > *Return ("imgdisp1.aspx?id="** &
strarguement)*
> > *End Function* **
> > **
> > *this function passes the snoart as string
argument to page imgdisp1*
> > *coding for which is:---*
> > **
> > *
> > Protected Sub Page_Load(ByVal sender As Object,
ByVal e AsSystem.EventArgs)
> > Handles Me.Load
> > Try
> > Dim strimageid As String =
Request.QueryString("id")
> > Dim conn As New
SqlConnection(ConfigurationManager.ConnectionStrings(
> >
"erpfmgConnectionString").ConnectionString)
> > Dim cmd3 As SqlCommand conn.Open()
> > cmd3 =
> > New SqlCommand("select * from catalogmast
where snoart=" & strimageid,
> > conn)
> > 'cmd3 = New SqlCommand("select * from
photos", conn)
> > Dim rdimg As SqlDataReader rdimg =
cmd3.ExecuteReader
> >
> > Do While (rdimg.Read())
Response.BinaryWrite(rdimg.Item(
> > "sampimg"))
> > Loop conn.Close()
> >
> > Catch ex As Exception
> > End Try
> >
> >
> > End Sub
> > *this is the coding i have used the problem is
when i make changes and
> > updates the virtual directory with new changes
then it stops showing image
> > and after 1-2 days it starts showing image. Also
in between it stops showing
> > image for articles which it used to show. Note:---
All the articles
> > have image uploaded and saved...so there is no
question of Null Values...
> > below is the code i used to save image to
database:---
> >
> > If
> > FileUpload1.HasFile Then
> > If FileUpload1.PostedFile.ContentType <>
"image/pjpeg"
AndFileUpload1.PostedFile.ContentType <>
> > "image/gif" And
FileUpload1.PostedFile.ContentType <>
"image/bmp" AndFileUpload1.PostedFile.ContentType
<>
> > "image/jpeg" Then lblmsg.Text =
> > "Select Image File Only"
> > Exit Sub
> > End If
> >
> > Dim reader As IO.BinaryReader =
NewIO.BinaryReader(FileUpload1.PostedFile.InputStream)
> > Dim image() As Byte =
> >
reader.ReadBytes(FileUpload1.PostedFile.ContentLength)
> > Dim insertSql As String = "INSERT INTO
catalogmast
> >
(sampname,sampdesc,sampimg,arttype,artdesign,buyfrm,buydept)
VALUES
> > ( samp, desc, Photo1, arttype, artdesign, buyfrm, buydept)" cmd2 =
> > New SqlCommand(insertSql, conn)
cmd2.Parameters.Add(
> > " samp", SqlDbType.NVarChar, 50)
cmd2.Parameters(
> > " samp").Value = Trim(txtname.Text)
cmd2.Parameters.Add(
> > " desc", SqlDbType.NVarChar, 200)
cmd2.Parameters(
> > " desc").Value = Trim(txtdesc.Text)
> > cmd2.Parameters.Add(
> > " Photo1", SqlDbType.Image)
cmd2.Parameters(
> > " Photo1").Value = image
cmd2.Parameters.AddWithValue(
> > " arttype",
DropDownList2.SelectedItem.Text)
> > cmd2.Parameters.AddWithValue(
> > " artdesign",
DropDownList4.SelectedItem.Text)
> > cmd2.Parameters.AddWithValue(
> > " buyfrm", ddbuyer.SelectedItem.Text)
cmd2.Parameters.AddWithValue(
> > " buydept", dddept.SelectedItem.Text)
cmd2.ExecuteNonQuery()
> >
> > end if
> > conn.Close()
> > lblmsg.Text =
> > "Sample Data Saved Successfully" the
above coding is in transaction with
> > one more query and with try catch.......
> > Hope i have made problem clear now.....
> > Waiting for reply.................
> > Regards
> >
> > Dipak
> >
> >
> > On Tue, Apr 22, 2008 at 5:41 PM, Tim Curtin
<tjc_tek hotmail.com> wrote:
> >
> > - can you post the code/html for the grid?
> > - did you check that the field is not null on the
server?
> > - are you using a page/handler to write the bits
back to the page-image?
> > - are you setting the correct mime type for the
image output?
> > - how are you retrieving the image?
> >
> >
> >
> >
> > ------------------------------
> > Date: Tue, 22 Apr 2008 12:42:11 +0530
> >
> > From: mishradipak gmail.com
> > To: aspnet-databases aspadvice.com
> > Subject: [aspnet-databases] RE: Error displaying
images in gridview
> >
> > Tim,
> > It shows image individually always... not in grid
view.... while
> > sometimes it shows image even in grid view.
> > Regards
> > Surendra
> >
> > On Mon, Apr 21, 2008 at 5:41 AM, Tim Curtin
<tjc_tek hotmail.com> wrote:
> >
> > Well, not knowing your app, the only things that
come to mind are that
> > the image field in the database is null or the url
from the page that is
> > creating the web image (<img
src='fetchImage.aspx?id=123'> ) is perhaps to
> > another domain and getting shut down by security
on the server. Other than
> > that, can you post the code that is retrieving the
image?
> >
> > ------------------------------
> > Date: Mon, 21 Apr 2008 00:35:53 +0530
> > From: mishradipak gmail.com
> > To: aspnet-databases aspadvice.com
> > Subject: [aspnet-databases] RE: Error displaying
images in gridview
> >
> > Also the link http://msdn2.microsoft.com/en-us/library/aa479350.aspx
> > displays picture from url stored in database not
from image itself stored in
> > database.
> > while the 2nd link shows how to store image to
database and read image
> > from database singly.. but the problem i am
facing is that sometimes its
> > not displayed in gridview wherein i have converted
a column to template
> > insert a image box into it and pass serial no as
primary key to other page
> > (where i am reading image and displaying it by
response.write (bibary
> > thing) whose url i am setting as url for image
control.
> > So may be now my problem is clearer.
> > Regards
> > Dipak
> > Thanks in Advance
> >
> > On Mon, Apr 21, 2008 at 12:26 AM, dipak mishra
<mishradipak gmail.com>
> > wrote:
> >
> > Thanks TIM, Rafeeq , and others for help,
> > I think i have not made myself clear i am getting
the images to be
> > displayed ... storing or displaying image is anot
an issue.... but the
> > problem is that at my clients place it sometimes
stops showing the images in
> > grid view.... while it shows on image box
individually..
> > Regards
> > Dipak
> >
> > On Fri, Apr 18, 2008 at 6:17 PM, Rafeeq .
<kpmrafeeq gmail.com> wrote:
> >
> > Yes Tim,
> >
> > I think he can apply the same concept to display
the image.
> >
> > --
> > Regards,
> > >Rafeeq
> > >Keralam
> >
> > On Fri, Apr 18, 2008 at 5:46 PM, Tim Curtin
<tjc_tek hotmail.com> wrote:
> >
> > > Rafeeq, this is old ADO. I think Dipak
wants ADO.Net.
> > >
> > > > Date: Fri, 18 Apr 2008 13:06:43 +0530
> > > > From: kpmrafeeq gmail.com
> > > > Subject: [aspnet-databases] RE: Error
displaying images in gridview
> > >
> > > > To: aspnet-databases aspadvice.com
> > > >
> > > > Hi Dipak,
> > > >
> > > > Try below method.
> > > >
> > > > str = "SELECT image FROM album
where id =" & ID
> > > > rs.Open str, conn
> > > > if rs.eof then 'No records found
> > > > Response.End
> > > > else 'Display the contents
> > > > Response.ContentType =
"image/gif"
> > > >
Response.BinaryWrite(rs("image"))
> > > > end if
> > > >
> > > > You can use red highlighted code in the
grid, if you are using
> > extended
> > > > grid.
> > > >
> > > > As you are storing it as binary format.
you need to reload it in
> > binary,
> > > > try.. this
> > > >
> > > > Happy coding,
> > > > --
> > > > With Warm Regards,
> > > >
> > > > >Rafeeq
> > > > >Keralam
> > > >
> > > >
> > > >
> > > >
> > > > On Fri, Apr 18, 2008 at 12:51 PM, dipak
mishra <
> > mishradipak gmail.com>
> > > > wrote:
> > > >
> > > > > Dear Allen,
> > > > > I am storing Image itself in
database not the path to it.
> > > > > How to display that using image
field.
> > > > > I am not able to do so.
> > > > > Plz Help
> > > > >
> > > > > On 4/18/08, Allen Moon
<howlmoon clearwire.net> wrote:
> > > > > > Hey there
> > > > > > In ASP 2.0 there is a
ImageField in gridview that you need to
> > use.
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: dipak mishra
[mailto:mishradipak gmail.com]
> > > > > > Sent: Thursday, April 17, 2008
1:15 PM
> > > > > > To: aspnet-databases aspadvice.com
> > > > > > Cc: aspnet-databases aspadvice.com
> > > > > > Subject: [aspnet-databases]
Error displaying images in gridview
> > > > > >
> > > > > > Hi All,
> > > > > > I am facing a problem on which
i would like to have suggestions.
> > > > > > I have an ERP Application in
ASP.net 2.0 with sql 2005 as back
> > end.
> > > I am
> > > > > > storing images in database
then i am displaying it on a page and
> > > giving
> > > > > the
> > > > > > URL of that page in grid view
template field which has a image
> > > control.
> > > > > > Same thins i have been doing
in application developed in asp 1.0
> > and
> > > sql
> > > > > 7.0
> > > > > > the images are displayed
correctly everywhere.
> > > > > > But in this application in
Grid view the same image have stopped
> > > being
> > > > > > displayed. Although if i view
them individually on other page
> > they
> > > are
> > > > > > displayed correctly.
> > > > > > The client has genuine sql
server.with service pack 2. Same
> > things
> > > are
> > > > > > working fine on my development
machine and similar thing is
> > running
> > > fine
> > > > > in
> > > > > > asp 1.0 and sql 7.0.
> > > > > > It was running fine on this
clients system too. All of a sudden
> > this
> > > is
> > > > > not
> > > > > > displaying image in grid
view.
> > > > > > I have reinstalled sql2005
still same problem.
> > > > > > The images are saved in sql
2005 this i have checked also the
> > images
> > > are
> > > > > > displayed correctly
individually which proves images are in fact
> > > saved
> > > > > > actually.
> > > > > > Any help will be graetly
appreciated since i am stuck
> > > > > > Regards
> > > > > > Dipak
> > > > > >
> > > > > >
> > > > > >
> > > > > > Need SQL Advice? http://sqladvice.com
> > > > > > Need RegEx Advice? http://regexadvice.com
> > > > > > Need XML Advice? http://xmladvice.com
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Need SQL Advice? http://sqladvice.com
> > > > > > Need RegEx Advice? http://regexadvice.com
> > > > > > Need XML Advice? http://xmladvice.com
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Need SQL Advice? http://sqladvice.com
> > > > > > Need RegEx Advice? http://regexadvice.com
> > > > > > Need XML Advice? http://xmladvice.com
> > > > > >
> > > > > >
> > > > > >
> > > > > > Need SQL Advice? http://sqladvice.com
> > > > > > Need RegEx Advice? http://regexadvice.com
> > > > > > Need XML Advice? http://xmladvice.com
> > > > > >
> > > > > >
> > > > > >
> > > > > > Need SQL Advice? http://sqladvice.com
> > > > > > Need RegEx Advice? http://regexadvice.com
> > > > > > Need XML Advice? http://xmladvice.com
> > > > > >
> > > > >
> > > > > Need SQL Advice? http://sqladvice.com
> > > > > Need RegEx Advice? http://regexadvice.com
> > > > > Need XML Advice? http://xmladvice.com
> > > > >
> > > >
> > > >
> > > >
> > > > Need SQL Advice? http://sqladvice.com
> > > > Need RegEx Advice? http://regexadvice.com
> > > > Need XML Advice? http://xmladvice.com
> > >
> > > ------------------------------
> > > Pack up or back up–use SkyDrive to transfer
files or keep extra
> > copies. Learn
> > > how.<
> > http:/
/www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_W
L_Refresh_skydrive_packup_042008>Need
> > SQL Advice?
> > > http://sqladvice.com
> > > Need RegEx Advice? http://regexadvice.com
> > > Need XML Advice? http://xmladvice.com
> > >
> >
> >
> >
> > --
> > With Warm Regards,
> >
> > >Rafeeq
> > >Keralam
> >
> >
> >
> > Need SQL Advice? http://sqladvice.com
> > Need RegEx Advice? http://regexadvice.com
> > Need XML Advice? http://xmladvice.com
> >
> >
> >
> > Need SQL Advice? http://sqladvice.com Need
RegEx Advice?
> > http://regexadvice.com
Need XML Advice? http://xmladvice.com
> >
> >
> > ------------------------------
> > Going green? See the top 12 foods to eat
organic.<http://green.msn.com/galle
ries/photos/photos.aspx?gid=164&ocid=T003MSN51N1653A>
> > Need SQL Advice? http://sqladvice.com
> > Need RegEx Advice? http://regexadvice.com
> > Need XML Advice? http://xmladvice.com
> >
> >
> > Need SQL Advice? http://sqladvice.com Need
RegEx Advice?
> > http://regexadvice.com
Need XML Advice? http://xmladvice.com
> >
> >
> > ------------------------------
> > Back to work after baby– how do you know when
you're ready?<http://lifestyle.msn.com/familyandparenting/articleNW.aspx?
cp-documentid=5797498&ocid=T067MSN40A0701A>Need
SQL Advice?
> > http://sqladvice.com
> > Need RegEx Advice? http://regexadvice.com
> > Need XML Advice? http://xmladvice.com
> >
> >
> > Need SQL Advice? http://sqladvice.com Need
RegEx Advice?
> > http://regexadvice.com
Need XML Advice? http://xmladvice.com
> >
> >
> > ------------------------------
> > Express yourself wherever you are. Mobilize!<http://www
.gowindowslive.com/Mobile/Landing/Messenger/Default.aspx?Loc
ale=en-US?ocid=TAG_APRIL>Need SQL Advice?
> > http://sqladvice.com
> > Need RegEx Advice? http://regexadvice.com
> > Need XML Advice? http://xmladvice.com
> >
>
> Need SQL Advice? http://sqladvice.com Need
RegEx Advice?
> http://regexadvice.com
Need XML Advice? http://xmladvice.com
>
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
|
Dipak, did you add the code in 'Catch' to write out an exception to a label control?
> Date: Tue, 29 Apr 2008 18:12:30 +0530 > From: kpmrafeeq gmail.com > Subject: [aspnet-databases] RE: Error displaying images in gridview > To: aspnet-databases aspadvice.com > > Hi Dipak, > > Just a thought, Try if you have any problem on connecting to the database > server from production instance, as it working on development instance even > remotely, Just have a look if any issue with connection from production > instance. > > *Regards, > Rafeeq > Keralam.* > > On Tue, Apr 29, 2008 at 5:57 PM, dipak mishra <mishradipak gmail.com> wrote: > > > Dear Tim, Rafeeq, > > I tried the code but again its not showing Images in Grid View. > > I dont know wats the prob with it. > > It Shows images on my development machine but not on system. > > My payment is stuck bcos of this error.Since on developments machine it > > works well .... while on client side it sometimes stops showing the > > image.Also same data base works well on our system. > > > > Need Help.Dont know wat to do..since no error on develpmnt system. > > > > Regards > > > > > > > > On Wed, Apr 23, 2008 at 7:27 PM, Tim Curtin <tjc_tek hotmail.com> wrote: > > > > > 1. Maybe you're supressing an exception. write it out to a label > > > control. > > > 2. try setting the response.contenttype before you response.binarywrite > > > the image bits. > > > *Do While** (rdimg.Read()) * > > > * Response.ClearHeaders()* > > > * Response.ClearContent()* > > > * Response.ContentType = "image/jpg"* > > > Response.BinaryWrite(rdimg.Item("sampimg")) > > > > > > Loop > > > > > > Incidently, you should add a 'Finally' where you close the connection. > > > Finally always runs regardless of an exception > > > > > > sub page_load(...) > > > Me.lblMessage.Text = "" > > > end sub > > > > > > function theFunction > > > > > > > > > dim con as new SqlConnection() > > > Try > > > con.connectionstring = > > > ConfigurationManager.ConnectionStrings("connectionstring").connectionstring > > > ....... > > > > > > Catch ex As Exception > > > Me.lblMessage.Text = ex.Message 'View an exception > > > Finally > > > If con.State <> ConnectionState.Closed() Then con.Close() > > > End Try > > > > > > > > > Tim > > > > > > ------------------------------ > > > Date: Wed, 23 Apr 2008 10:36:49 +0530 > > > > > > From: mishradipak gmail.com > > > To: aspnet-databases aspadvice.com > > > Subject: [aspnet-databases] RE: Error displaying images in gridview > > > > > > Dear Tim > > > here is the code............ for grid view...............SampImg is the > > > name of the column to display image which has been converted to templte > > > column ..........formaturl is the function used to pass the sno which is > > > identity and primary key. > > > > > > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" > > > CellPadding="4" > > > DataKeyNames="snoart" DataSourceID="SqlDataSource4" ForeColor="#333333" > > > GridLines="None" AllowPaging="True" AllowSorting="True"> > > > <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> > > > <Columns> > > > <asp:CommandField ShowSelectButton="True" /> > > > <asp:BoundField DataField="snoart" HeaderText="SNoArt" InsertVisible > > > ="False" ReadOnly="True" > > > SortExpression="snoart" /> > > > <asp:BoundField DataField="sampname" HeaderText="SampName" > > > SortExpression="sampname" /> > > > <asp:BoundField DataField="artdesign" HeaderText="ArtDesign" > > > SortExpression="artdesign" /> > > > <asp:TemplateField HeaderText="SampImg" SortExpression="sampimg"> > > > <EditItemTemplate> > > > <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("sampimg") %> > > > '></asp:TextBox> > > > </EditItemTemplate> > > > <ItemTemplate> > > > <asp:Image ID="Image1" width="75" Height="75" runat="server" ImageUrl='<%# > > > formaturl(databinder.Eval(container.dataitem,("snoart"))) %>' /> > > > </ItemTemplate> > > > </asp:TemplateField> > > > </Columns> > > > <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> > > > <EditRowStyle BackColor="#999999" /> > > > <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor > > > ="#333333" /> > > > <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign > > > ="Center" /> > > > <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> > > > <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> > > > </asp:GridView> > > > > > > > > > > > > > > > then there is this format url function in code behind page:-- > > > > > > > > > *Function formaturl(ByVal strarguement) As String* > > > *Return ("imgdisp1.aspx?id="** & strarguement)* > > > *End Function* ** > > > ** > > > *this function passes the snoart as string argument to page imgdisp1* > > > *coding for which is:---* > > > ** > > > * > > > Protected Sub Page_Load(ByVal sender As Object, ByVal e AsSystem.EventArgs) > > > Handles Me.Load > > > Try > > > Dim strimageid As String = Request.QueryString("id") > > > Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings( > > > "erpfmgConnectionString").ConnectionString) > > > Dim cmd3 As SqlCommand conn.Open() > > > cmd3 = > > > New SqlCommand("select * from catalogmast where snoart=" & strimageid, > > > conn) > > > 'cmd3 = New SqlCommand("select * from photos", conn) |