473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

help, my program runs to fast!

Hi,

I made a webform for a survey, with multiple-choice questions. The results
of each question is put into a table e.g.:
values frequency
1 6
2 3
3 32
4 26
5 12

Now i want to add a graphic beside the table representing those values. So i
use two files, the second containing the code for the graphic.
I tried two ways: with a cookie and with passing a parameter. Everything
works, except that the second file has no time to create and render the
graphic.

When using a cookie, all graphics are rendered in file 1 but all with the
values of the last question.
When using a parameter, only the graphic of the last question is rendered
(with the right values).

Do you know a way to 'slow down' file1, so file2 has enough time to produce
and send the graphic to file 1? Or any other solution?

Thanks
André


My code:

file1: (with parameter)
-----
'valtopass is the string containing the values to pass with ':' as separator
(e.g. 6:3:32:26:12)
....
For j = 1 To numberoffield
'create table
....
gr.ImageUrl = "graf2.aspx?v1=" & valtopass
form1.Controls.Add(gr)
next
....

file1: (with cookie)
-----
'valtopass is the string containing the values to pass with ':' as separator
(e.g. 6:3:32:26:12)
'cok = HttpCookie
....
For j = 1 To numberoffield
'create table
....
cok.value=valtopass
response.cookies.add(cok)
next
....

Dec 1 '06 #1
6 1553
"André" <hjhhb@ddwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
Or any other solution?
Don't take this the wrong way, but you really should get hold of a
beginner's guide to ASP.NET and work your way through it. You mentioned in a
previous post that you are a newbie - which is fine, we were all newbies
once - but you are getting yourself into horrible tangles here trying to
accomplish something which is, in fact, incredibly simple if you just use
ASP.NET properly.

For one thing, you don't need two files for this. You say you want to
display some records out of a datatable textually and graphically - well use
a DataGrid or a Repeater - that's what these controls are for.

And secondly, and far more importantly, you really must get out of the habit
of using cookies to persist state across aspx pages - that isn't what
they're for at all. You might also be surprised to know how many people have
their browser configured not to accept cookies by default...
Dec 1 '06 #2
Thanks anyway for replying ...
What i have done is programmatically create a form with radiobuton,
dropdownlist etc ...for any kind of survey. The program reads from an excel
sheet the questions and type of questions (open, not open, min/max values
etc ..) and in function of all those parameters, the program create a
inputform. The program then calculate the statistics and show them in tables
(one per question). I do use datereader and tables.
This part works great, but what i would like to do is beside each table,
create a little 2-D bitmap graphic representing the frequenties. So to my
knowledge (and according others experts in this group), that bitmap graphic
must be created in another page and called from the first page. This also
works great (with one table and one graphic), except when there are a lot of
graphics to make (one per question).

So, please Mark, don't think i'm a fool who can nearly read or something. I
have a actual problem: how to get those bitmap graphics beside each table
into page 1? Is this problem so weird, so stupid or ridiculus? Not to me
anyway.
I would very much appreciate if you could help me. About the cookie, i agree
with you. I hope you noticed I tried another solution with sending a
parameter. But that doesn't work, so i try something else with cookies. Is
there more, better solutions? Tell me then. Please

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:OP**************@TK2MSFTNGP05.phx.gbl...
"André" <hjhhb@ddwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
>Or any other solution?

Don't take this the wrong way, but you really should get hold of a
beginner's guide to ASP.NET and work your way through it. You mentioned in
a previous post that you are a newbie - which is fine, we were all newbies
once - but you are getting yourself into horrible tangles here trying to
accomplish something which is, in fact, incredibly simple if you just use
ASP.NET properly.

For one thing, you don't need two files for this. You say you want to
display some records out of a datatable textually and graphically - well
use a DataGrid or a Repeater - that's what these controls are for.

And secondly, and far more importantly, you really must get out of the
habit of using cookies to persist state across aspx pages - that isn't
what they're for at all. You might also be surprised to know how many
people have their browser configured not to accept cookies by default...

Dec 1 '06 #3
"André" <hjhhb@ddwrote in message
news:eK**************@TK2MSFTNGP04.phx.gbl...
This part works great, but what i would like to do is beside each table,
create a little 2-D bitmap graphic representing the frequenties. So to my
knowledge (and according others experts in this group), that bitmap
graphic must be created in another page and called from the first page.
This also works great (with one table and one graphic), except when there
are a lot of graphics to make (one per question).
Well, I don't know who told you that - there is absolutely no need to use
two pages for this.
So, please Mark, don't think i'm a fool who can nearly read or something.
I have a actual problem: how to get those bitmap graphics beside each
table into page 1? Is this problem so weird, so stupid or ridiculus? Not
to me anyway.
Don't shoot the messenger, mate... The problem isn't weird, stupid or
ridiculous - you've obviously been given bad advice.
I would very much appreciate if you could help me.
Here's a quick and dirty page I knocked up in about five minutes - no need
for messing about with bitmap graphics or whatever...
I hope this is the sort of thing you're looking for (code is below).
Obviously, I have hard-coded the data and you will be fetching it from a
database, but the concept is the same.

http://www.markrae.com/zzScratch/TestBars.aspx
About the cookie, i agree with you. I hope you noticed I tried another
solution with sending a parameter. But that doesn't work, so i try
something else with cookies. Is there more, better solutions? Tell me
then. Please
Are you not, then, fetching the data from a database? In which case, you
don't actually need to pass anything anywhere - just read it when you need
it...

However, in ASP.NET if you need to persist data across more than one page,
you have several choices:

1) you can append the data to the target URL in a querystring e.g.
test.aspx?id=1&value=2

2) you can use the Session object to store the value(s)

3) in ASP.NET 2, you can post from one page to another

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestBars.aspx.cs"
Inherits="zzScratch_TestBars" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Dynamically sized graphics</title>
</head>

<body>
<form id="form1" runat="server">
Change the values in the boxes and click here <asp:Button ID="cmdRedraw"
runat="server" Text="Redraw" OnClick="cmdRedraw_Click" /><br />
<br />
<asp:Table ID="tblBars" runat="server">
<asp:TableHeaderRow>
<asp:TableHeaderCell Text="Value" HorizontalAlign="Left" />
<asp:TableHeaderCell Text="Frequency" HorizontalAlign="Left" />
<asp:TableHeaderCell Text="Graphic" HorizontalAlign="Left" />
</asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell Text="1" />
<asp:TableCell><asp:TextBox runat="server" Text="6" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="60px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="2" />
<asp:TableCell><asp:TextBox runat="server" Text="3" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="30px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="3" />
<asp:TableCell><asp:TextBox runat="server" Text="32" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="320px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="4" />
<asp:TableCell><asp:TextBox runat="server" Text="26" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="260px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="5" />
<asp:TableCell><asp:TextBox runat="server" Text="12" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="120px"
/></asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>

using System;
using System.Web.UI.WebControls;

public partial class zzScratch_TestBars : System.Web.UI.Page
{
protected void cmdRedraw_Click(object sender, EventArgs e)
{
foreach (TableRow objTR in tblBars.Rows)
{
if (objTR.GetType().Name == "TableRow")
{
((Label)objTR.Cells[2].Controls[0]).Width =
Unit.Pixel(Convert.ToInt32(((TextBox)objTR.Cells[1].Controls[0]).Text) *
10);
}
}
}
}
Dec 2 '06 #4
I admit that your solution is easier than working with bitmap graphics, but
you must admit that this graphic is very simple. With the
'System.Drawing.Imaging ' namespace, you can do a lot more (pie, lines etc
...), and in that case, you need two files (see another of my threads "how to
render a graphic ..." frm 27/11 and the answer of Steve Orr (MCSD, MVP, CSM,
ASPInsider).
So, if i can't find a solution on my problem, i will use yours.
The data in the database are the values inputted by people who answered the
question. So the program first calculate all statistics, and those values,
for each question, must be passed to the graphic.

But i still wonder why only the last graphic is rendered back to page 1. I
can't see any bug in my code, nor a logical error. A matter of speed, i
thing: the tag <img ...?....referning and passing the right data to the
graphic, then the creation of the graphic and back to the file 1 takes too
long. During that operation, the loop between all questions goes further,
passing new data to the file 2.

Anyway, thanks for your advices and time

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:ee**************@TK2MSFTNGP04.phx.gbl...
"André" <hjhhb@ddwrote in message
news:eK**************@TK2MSFTNGP04.phx.gbl...
>This part works great, but what i would like to do is beside each table,
create a little 2-D bitmap graphic representing the frequenties. So to my
knowledge (and according others experts in this group), that bitmap
graphic must be created in another page and called from the first page.
This also works great (with one table and one graphic), except when there
are a lot of graphics to make (one per question).

Well, I don't know who told you that - there is absolutely no need to use
two pages for this.
>So, please Mark, don't think i'm a fool who can nearly read or something.
I have a actual problem: how to get those bitmap graphics beside each
table into page 1? Is this problem so weird, so stupid or ridiculus? Not
to me anyway.

Don't shoot the messenger, mate... The problem isn't weird, stupid or
ridiculous - you've obviously been given bad advice.
>I would very much appreciate if you could help me.

Here's a quick and dirty page I knocked up in about five minutes - no need
for messing about with bitmap graphics or whatever...
I hope this is the sort of thing you're looking for (code is below).
Obviously, I have hard-coded the data and you will be fetching it from a
database, but the concept is the same.

http://www.markrae.com/zzScratch/TestBars.aspx
>About the cookie, i agree with you. I hope you noticed I tried another
solution with sending a parameter. But that doesn't work, so i try
something else with cookies. Is there more, better solutions? Tell me
then. Please

Are you not, then, fetching the data from a database? In which case, you
don't actually need to pass anything anywhere - just read it when you need
it...

However, in ASP.NET if you need to persist data across more than one page,
you have several choices:

1) you can append the data to the target URL in a querystring e.g.
test.aspx?id=1&value=2

2) you can use the Session object to store the value(s)

3) in ASP.NET 2, you can post from one page to another

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestBars.aspx.cs"
Inherits="zzScratch_TestBars" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Dynamically sized graphics</title>
</head>

<body>
<form id="form1" runat="server">
Change the values in the boxes and click here <asp:Button ID="cmdRedraw"
runat="server" Text="Redraw" OnClick="cmdRedraw_Click" /><br />
<br />
<asp:Table ID="tblBars" runat="server">
<asp:TableHeaderRow>
<asp:TableHeaderCell Text="Value" HorizontalAlign="Left" />
<asp:TableHeaderCell Text="Frequency" HorizontalAlign="Left" />
<asp:TableHeaderCell Text="Graphic" HorizontalAlign="Left" />
</asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell Text="1" />
<asp:TableCell><asp:TextBox runat="server" Text="6" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="60px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="2" />
<asp:TableCell><asp:TextBox runat="server" Text="3" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="30px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="3" />
<asp:TableCell><asp:TextBox runat="server" Text="32" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="320px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="4" />
<asp:TableCell><asp:TextBox runat="server" Text="26" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="260px"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="5" />
<asp:TableCell><asp:TextBox runat="server" Text="12" Width="20px"
MaxLength="2" /></asp:TableCell>
<asp:TableCell><asp:Label runat="server" BackColor="Red" Width="120px"
/></asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</html>

using System;
using System.Web.UI.WebControls;

public partial class zzScratch_TestBars : System.Web.UI.Page
{
protected void cmdRedraw_Click(object sender, EventArgs e)
{
foreach (TableRow objTR in tblBars.Rows)
{
if (objTR.GetType().Name == "TableRow")
{
((Label)objTR.Cells[2].Controls[0]).Width =
Unit.Pixel(Convert.ToInt32(((TextBox)objTR.Cells[1].Controls[0]).Text) *
10);
}
}
}
}

Dec 3 '06 #5
"André" <hjhhb@ddwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I admit that your solution is easier than working with bitmap graphics, but
you must admit that this graphic is very simple.
It certainly is.
With the 'System.Drawing.Imaging ' namespace, you can do a lot more (pie,
lines etc ..), and in that case, you need two files (see another of my
threads "how to render a graphic ..." frm 27/11 and the answer of Steve
Orr (MCSD, MVP, CSM, ASPInsider).
OK.
Dec 3 '06 #6
So, if i want some more sophisticated graphic for each question, i must use
the 'System.Drawing.Imaging' and so i'm back to the starting point: how to
get beside each table the appropriate graphic or why do i only get the
graphic of the last question?

But i thing you spend enough time to me, so i'll repost it and reformulate
it more clearly.
Thanks

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
"André" <hjhhb@ddwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>I admit that your solution is easier than working with bitmap graphics,
but you must admit that this graphic is very simple.

It certainly is.
>With the 'System.Drawing.Imaging ' namespace, you can do a lot more (pie,
lines etc ..), and in that case, you need two files (see another of my
threads "how to render a graphic ..." frm 27/11 and the answer of Steve
Orr (MCSD, MVP, CSM, ASPInsider).

OK.

Dec 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kevin T. Ryan | last post by:
Hi All - I'm trying to develop web applications using python / Cheetah. I'm also trying to experiment with lighttpd (see www.lighttpd.net), which supports fast-cgi. So, I downloaded Robin...
1
by: Voss | last post by:
Here's what's going on. I have a 2 computers (x & y) running SQL2000. I backed up a copy a DB from x and restored it on y. I have a Stored proc that runs in under 2 seconds on both x & y when...
2
by: AG | last post by:
I am able to run a query which runs FAst in QA but slow in the application.It takes about 16 m in QA but 1000 ms on the Application.What I wanted to know is why would the query take a long time...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
6
by: matt.b.williams | last post by:
I am writing a program for a handheld device. It is a simple C program and it runs in a DOS like environment. I'm compiling it in Microsoft Visual C v1.x. Anyway, as part of this application, I...
5
by: john009 | last post by:
hmmmm...thanks to all that are willing to help i am using VB 6...theres more than one question i wish to ask please bare with me...i have to read in information from a file which the program...
41
by: c | last post by:
Hi every one, Me and my Cousin were talking about C and C#, I love C and he loves C#..and were talking C is ...blah blah...C# is Blah Blah ...etc and then we decided to write a program that...
6
by: Jajjo | last post by:
Hey there, I'm making a program for my course and it's going pretty well so far, but there is a problem. When I'm at school, the program runs fine. At the speed I want it to. When I get home,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.