Showing posts with label instead. Show all posts
Showing posts with label instead. Show all posts

Saturday, March 24, 2012

Ole object

I want to display pictures from access database in repeater but instead i receive some
windows with red crosses.
It should be a good solution but it dont work.
This is my .aspx code (well its not main i copied it from another site for my learnigs):

<%@dotnet.itags.org. Import Namespace="System.Data.OleDb" %><script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("/photolib.mdb"))

dbconn.Open()
sql="SELECT smallimage FROM photo"
--smallimage is an OLE object column connected with .jpg files in my database
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
photo.DataSource=dbread
photo.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script
<form runat="server">
<asp:Repeater id="photo" runat="server"><HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Small Image</th>
</tr>
</HeaderTemplate><ItemTemplate>
<tr>
<td><img src="http://pics.10026.com/?src=<%#Container.DataItem("smallimage")%>"></td
</tr>
</ItemTemplate><FooterTemplate>
</table>
</FooterTemplate></asp:Repeater>
</form
Thanks for any tips or ideas you can give me.The img src attribute should be specified with a location of the file, not the file data itself. One possible way is to have the pictures stored as files on the webserver, and have the field smallimage of the database table points to the corresponding picture file as a relative url. Then when loading the page, the web browser would be able to request the picture file according to the url specified to the src attribute of img tag.
Hi,

In the src of your image, you're supposed to put the URL where the browser will find the picture. Here, you're giving it the image itself. The browser fails to see a valid url there, and displays a red cross.
What you want to do is build a HttpHandler that will get some photo id as a url parameter. in the img src, put the address of the handler (something like blah.ashx?photoid=25).
The handler will send the contents of the image field of your database directly to the response binary stream and set the content type.
Checkthis for a tutorial (even though they should use a HttpHandler instead of an aspx page).

Let me know if this helps.

(BTW, there's a strange header thing in OLE fields in Access which may force you to skip the first 16 or something bytes of the field)
Thanks.
But i already have my .jpg files stored on my webserver, besides i have this files connected to smallimage column in database (access 2000 allows to make .jpg files elemet of database file and that is exactly what i have done).Shouldn't .aspx file read picture data directly from database in this case.
Thanks.
Yes, putting direct source to all .jpg files would propably solve the thing.But i have made .jpg files elemet of database file.Shouldn't .aspx file read picture data directly from database in this case.The other solution (httphandler) lies so far beyond my knowledge(I'm rather a begginer in asp.net).
Sorry. First reply is to Frank Tse and second to bleroy.
In your example the databind expression
<%#Container.DataItem("smallimage")%
does read the picture data from database and included in the response. However, the usage of the src attribute in img tag is expecting a URL to be specified, not the picture data itself (accroding to html spec).

So if you already have the pictures files on the server, all you need to bind the value to the src attribute is the location of the picture files. Otherwise, if the picture data must be retrieved from the database directly, you would need bleroy's HttpHandler approach.
My Access 2000 was the problem it didn't connect database ole object with .jpg file.I don't know why.I have convert my database to sql database.I have set my picture field as varchar.I set source of my pictures like that:
<img src="http://pics.10026.com/?src=image source"/<%# DataBinder.Eval
(Container.DataItem, "Column name") %>'

And now it works perfectly.
Anyway thanks for help.

Thursday, March 22, 2012

OleDbCommand TimeOut Not Working

Why does this timeout after 10 secs, instead of the higher value expected?

OleDbConnection cn = new OleDbConnection(Session["DataSource"].ToString());
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand(query, cn);
cmd.CommandTimeout = 99999;
adapter.SelectCommand = cmd;
adapter.Fill(ds,"data");
cn.Close();
adapter.Dispose();Are you sure it is and not something else timing out (page, etc).?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Chris Fink" wrote:

> Why does this timeout after 10 secs, instead of the higher value expected?
> OleDbConnection cn = new OleDbConnection(Session["DataSource"].ToString());
> OleDbDataAdapter adapter = new OleDbDataAdapter();
> OleDbCommand cmd = new OleDbCommand(query, cn);
> cmd.CommandTimeout = 99999;
> adapter.SelectCommand = cmd;
> adapter.Fill(ds,"data");
> cn.Close();
> adapter.Dispose();

OleDbCommand TimeOut Not Working

Why does this timeout after 10 secs, instead of the higher value expected?
OleDbConnection cn = new OleDbConnection(Session["DataSource"].ToString());
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand(query, cn);
cmd.CommandTimeout = 99999;
adapter.SelectCommand = cmd;
adapter.Fill(ds,"data");
cn.Close();
adapter.Dispose();Are you sure it is and not something else timing out (page, etc).?
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Chris Fink" wrote:

> Why does this timeout after 10 secs, instead of the higher value expected?
> OleDbConnection cn = new OleDbConnection(Session["DataSource"].ToString())
;
> OleDbDataAdapter adapter = new OleDbDataAdapter();
> OleDbCommand cmd = new OleDbCommand(query, cn);
> cmd.CommandTimeout = 99999;
> adapter.SelectCommand = cmd;
> adapter.Fill(ds,"data");
> cn.Close();
> adapter.Dispose();

Friday, March 16, 2012

On download, how to open .XSD file in its XML format instead Schema?

Hi,
I have one download link in my webform. On click, i have specified .XSD file to open. But it opens in Microsoft .Net Environment, and in Schema format.
My prob is, i want to open that .XSD file's Xml in Browser (Internet Explorer).
Thanx in advance.

I noticed you asked this in the Web Forms threadhttp://forums.asp.net/988565/ShowPost.aspx.
Have you tried that solution?