|
Call Dispose when you finish with a bitmap to clean up it's memory usage.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Did you read Christian's reply? Are you disposing your bitmaps?
Memory is managed by the framework - you can't expect the memory use
to go back to what it was before you create an object.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi all,
I have written a windows service which will delete the files from the respective folder.
Now I want to make my service only to run at every day night 8.00PM.
How to achieve above?
Kindly guide me...since new to these concepts
Thanks In Advance
|
|
|
|
|
|
Create a thread in the service that waits until the specified time every day, and the performs its processing.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
CrystalReportViewer control is disable in the Toolbox.How to make it enable (.Net2.0)
|
|
|
|
|
If you have selected Crystal Reports Application while creating the project I believe that you should have the viewer as enabled by default.
But if you have started with Windows Application, I can suggest you to make sure that your solution has a reference to Crystal Reports Engine.
Regards,
Always keep the Murphy Rules in mind!
|
|
|
|
|
hi i am new user of asp.net using c#
in master page there is a datalist in a panel which is filled by category table. but problem is that data goes out from panel. when i use content place holder then problem is that datalist is not filled nullvalue exception given. if i use iframe to solve this problem than problem is that when i click datalist link button to show another information than that show in that i frame not in other portion.
how i solver this problem.
thanks in advance.
|
|
|
|
|
umeshdaiya wrote: hi i am new user of asp.net using c#
OK. Obviously also a new user of this website. You asked in the ASP.NET forum, I think. Don't ask here, this is for non ASP.NET questions.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi, i've got a real problem with my login page.. It logs in the first time but when i log out and log in again. I get the following error:
System.InvalidOperationException: The connection was not closed. The connection's current state is open.
Here is my code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class login : System.Web.UI.Page
{
static String connectionString = WebConfigurationManager.ConnectionStrings["AEConnection"].ConnectionString;
static SqlConnection AEConnection = new SqlConnection(connectionString);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
String mysql = "select * from AELogin where username ='" + txt_Login.Text + "' and password = '" + txt_Pass.Text + "'";
SqlDataReader dr;
SqlCommand cmdLogin = new SqlCommand(mysql, AEConnection);
AEConnection.Open();
dr = cmdLogin.ExecuteReader();
if (txt_Login.Text == "" | txt_Pass.Text == "") {
Label1.Text = "Please make sure both your Username and Password are entered";
}
else if (dr.Read() == true) {
if (System.Convert.ToInt32(dr["alevel"]) == 1)
{
Session["accesslevel"] = "1";
Response.Redirect("adminHome.aspx");
}
else if (System.Convert.ToInt32(dr["alevel"]) == 2)
{
Session["accesslevel"] = "2";
Response.Redirect("guestHome.aspx");
}
}
else {
Label1.Text = "Wrong info";
Response.Redirect("Error.aspx");
}
AEConnection.Close();
dr.Close();
}
}
Hope that somebody could enlighten me on this situation as i've been stuck here for quite awhile and have yet to find a solution
thanks alot!
|
|
|
|
|
post it to asp.net forum
cheers,
Abhijit
|
|
|
|
|
use try,catch and finally statement
Raaj
|
|
|
|
|
jljx wrote: Response.Redirect("Error.aspx");
Buy a book on ASP.NET, or even one on C#. What do you think Response.Redirect does ? It is like a 'return' statement, it goes to a new page. So, your code doesn't run. So, a try/catch/finally statement is probably an elegant way around this problem, as someone suggested.
And yes, this is an ASP,NET question, you shold have asked there.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
dr.Close();
AEConnection.Close();
i think here u have done wrong, and before redirecting close your all connections
better use using block
and also there is no try catch finally block use them to tackle any runtime errors or db error.
|
|
|
|
|
try and guess what happens when I type the following into your "txt_Pass" textfield.
' or 1=1--
look up "sql injection" on this website.
|
|
|
|
|
Take a look at the using statement. This is an elegant way to handle this, so that your connections and commands get closed. For instance, here's a very simple implementation:
using (SqlConnection conn = new SqlConnection (connectionString))
{
using (SqlCommand cmd = new SqlCommand(cmdText))
{
... Do something with the database here.
Response.Redirect("Error.aspx");
}
} As the command and connection are wrapped in a using block, they are both disposed for you automatically (which also closes the command and connection). This command effectively creates a try/finally block where the finally contains the Dispose command for the relevant object.
|
|
|
|
|
Hi everybody
How can find out number of characters in a file?
Best Regards,
Reza Shojaee
|
|
|
|
|
File.ReadAllBytes.Count, or something like that
You may be able to get it from the FileInfo class also.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: File.ReadAllBytes.Count, or something like that
That'll work for ASCII and UTF-32, but not for UTF-8 and some other encodings with variable character length. File.ReadAllText(path).Length should work better.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Depends, if it's a text file or a binary file, and if he wants file size, or number of characters.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
using System.IO;
FileInfo info = new FileInfo("filename.txt");
long charCount = info.Length;
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
After spending the last few months reading about Test Driven Development I am a complete and utter believer. Unfortunately I'm still inexperienced and need advice on unit testing a class which incorporates a timer.
For example I am building an ActivityMonitor class which would be used to detect an activity timeout on a class (typically a mediator for a windows form) and reset it. I'm envisioning something like this:
ActivityMonitor
..private Timer _timer;
..private EventDelegate _timeout_callback;
..ActivityMonitor(EventDelegate callback, int timer_interval);
..public Reset();
How do I test something like TimeoutRaisesCallback? I could set the timer of course and wait for the callback but that would just slow down my unit tests. Do I merely set it to something very short like a few milliseconds and take the hit? Or is there a better standard way to handle this?
Also, suppose I have a class that uses the Activity Monitor:
ClassThatUsesActivityMonitor
..private ActivityMonitor _activity_monitor;
..ClassThatUsesActivityMonitor() {_activity_monitor = new ActivityMonitor(new EventDelegate(Reset));}
..public Reset();
..public DoSomething();
How do I go about unit testing that ClassThatUsesActivityMonitor reacts appropriately if the ActivityMonitor calls its Reset() function while DoSomething() is executing?
I look foreward to your responses, thank you very much,
Togakangaroo
|
|
|
|
|
umm...bump...not sure why I'm not getting a response
|
|
|
|