|
But my application is getting slower after the memory allocation gets increased.If the garbage collector works properly,then i should not get the out of memory exception.But iam getting that exception if the memory gets increased after a certain time,bcoz billing screen will be in the operation for the whole day.
So how to solve it!
Raji
|
|
|
|
|
Memory isn't the only thing that can cause an OutOfMemoryException. If you don't close and dispose of file handles or all GDI graphics objects used for drawing, or whatever else uses a system handle, you'll exhaust the handle pool and cause the same exception and even slower and slower performance.
Basically, you're looking at a complete review of your code to make sure your Disposing everything you should be when you're done with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In most cases it's better to just leave the garbage collector alone. The whole memory management in .NET relies on the garbage collector, and it does quite a good job. Almost always, the garbage collector has much better information on when to do it's job, than what you can anticipate while designing the application.
Don't look at the task manager if you want real memory usage statistics on .NET applications, for that you need something like .NET Profiler. Even if the memory is freed by the garbage collector, it's not released back to windows (unless needed), so you won't be able to monitor actual memory usage in the task manager.
---
b { font-weight: normal; }
|
|
|
|
|
But my application is getting slower after the memory allocation gets increased.If the garbage collector works properly,then i should not get the out of memory exception.But iam getting that exception if the memory gets increased after a certain time,bcoz billing screen will be in the operation for the whole day.
So how to solve it!
Raji
|
|
|
|
|
When the system runs out of memory, it first runs a garbage collection to see if there is anything to collect, before giving up and throwing an exception. So if you run out of memory it's more likely to be due to a memory leak in the application rather than a malfunction in the garbage collection.
Any object that are disposable (inherits the IDisposable interface e.g. having a Dispose method) have to be properly disposed, or they can not be garbage collected.
---
b { font-weight: normal; }
|
|
|
|
|
My name is Landon and I have started to teach myself programming. I am new to vb.Net and I can not figure out how to do a query based on what a user types in a text box. I have tried to figure it out on my own an I can't do it. Here is what I have right now:
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
TextBox2.Text = SqlDataSource1.SelectCommand("select * from EMPMST where EMP_NAME = (@[TextBoxt1.Text.ToString])")
ElseIf RadioButton2.Checked = True Then
TextBox2.Text = SqlDataSource1.SelectCommand("select * from EMPMST where EMP_CORP = (@[TextBoxt1.Text.ToString])")
ElseIf RadioButton3.Checked = True Then
TextBox2.Text = SqlDataSource1.SelectCommand("select * from EMPMST where EMP_SSN = (@[TextBoxt1.Text.ToString])")
End If
End Sub
End Class
If some one could help me or at least explain the concept I am looking for I would be very greatful.
-- modified at 17:41 Monday 9th January, 2006
|
|
|
|
|
What is this TextBox2 suppose to show? I hope it's not data because you haven't executed a query to return any.
But, to fix your SELECT statemnet and actually put the value of TextBox1 into the SELECT statement:
SqlDataSource1.SelectCommand="select * from EMPMST where EMP_SSN='" & TextBox1.Text & "'"
You don't need to put the .ToString() on the end of the TextBox1.Text statement because Text returns a String! Why try to convert a String to a String???
I would highly suggest picking up a book on VB.NET and SQL to get the basics down. There's a lot of misunderstandings coming through in your code. Way too many to discuss in the any forum.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Yeah, I know. His code is messed up in so many different directions, I didn't want his head to explode when he read your article.
But I do have your article bookmarked so I can refer people to it quickly!
Great job!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I see what you are saying. I am new to this thing and I have tried looking at a book ,but I have not found the question that I was looking for. I know I still need the book for all of the basic stuff I have not learned yet and this ia a problem that happens when you teach yorself. I think that I can make this code work though, The sqldatasource1 is a feature in Microsoft web development that has the connection and basic sql query. This could be like you said a dead end and I may have to start over and I will if that is what it comes to. Basically the best way I learn is to just sit down and try to make something. I have built several little programs and website in just a few weeks where if I was in a class or following the book I would not have been able to do this. I appreciate all of the advice that I have received though.
-- modified at 10:03 Tuesday 10th January, 2006
|
|
|
|
|
I do see what your saying because I'm completely self taught. There isn't a single computer class that I haven't walked into and been able to teach it on-the-fly.
But, there is so much wrong with your code on so many levels, I can't even begin to describe how to get it to work, other than scrapping it and starting over. Understand each line of code before you move on to the next. You have to understand what the classes your using require and how to build up those pre-req's first, like the SqlDataSource.
Landon Spann wrote: Basically the best way I learn is to just sit down and try to make something
Yes it is. The problem is your actually making it harder on yourself by not getting the basics first. You're trying to climb Mount Everest without having climbed a simple hill first. Learn to hike before your learn to climb. It'll make throwing these applications together much easier and quicker in the long run. Take it from someone who's been there and done it the hard way. Now that I have all the basics down and the concepts, I can pick up any language and write code using it, without having seen it before.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I appreciate the advice and before starting another project I will try to master the basics.
|
|
|
|
|
In addition to Dave's comments, you should NEVER use the text from a textbox in a select like this without first cleaning it to protect from injection attacks.
Like Dave said, you're really lost at sea here, you need to abandon this project for now, buy a beginners book and work through it. One other point - you should never keep the default variable names. What makes textbox1 different from textbox2 ? How about txtInput and txtOutput. See how that would make your code more readable ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi, my problem is that I have a tab control, consisting of 4 tab pages and 4 user controls, 1 user control on each tab page. I would like to call the event method tabcontrol.selectedindex changed to load the data into the user control when the user clicks on the form, and not immediately when the selected index is changed. I need this because when certain users open the application the application will hide/remove a tab page if the user does not have access to that particular page. Upon removal, visual studio.net sets the selected index to the page index immediately before the one being removed. My loading of data was originally located within the load method of the user control itself, but this is causing my application to lag at startup when I need to remove a tabpage because it is loading that page when I remove the tabpage.
My code currently looks like eg.:
Public Sub tcCompany_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tc_Company.SelectedIndexChanged
Select Case UCase(Me.tc_Company.SelectedTab.Name)
Case "TP_COMPANYNOTES" 'checks to see if user clicked the notes page
If Me.tcmediator.p_ucNotes.comb_companyName.Items.Count <= 0 Then 'checks if combo has data
Call Me.tcmediator.p_ucNotes.userClickedForm() 'loads data
End If
Case "TP_COMPANYCREDIT" 'checks to see if user clicked the credit page
If Me.tcmediator.p_ucCredit.comb_companyName.Items.Count <= 0 Then 'checks if combo has data
Call Me.tcmediator.p_ucCredit.userClickedForm() 'loads data
End If
end select
end sub
Thanks for the help
eatwork
|
|
|
|
|
Why not load your control when it becomes visible for the first time ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian, thank you for your input, I can't load the control during the load method of the control because the control on the 4th tab page loads immediately after deleting the 5th tab page, because the tab control automatically sets the selected index to the index of the control...not sure how to explain this, but if you delete tab page 5, then the tab control within visual studio will set the selected index to tab 4 upon loading the tab control. when that happens tab 4's load method will execute causing the loading of the form to be an extra 3 seconds slower than it needs to be. Not too sure if that answers your question/answer. or if I am way off base could you explain your solution a little more please? thank you.
eatwork
|
|
|
|
|
No, I meant during the visible changed event. When it becomes visible.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you Christian for your reply, sorry it took me so long to reply. I will give your suggestion a try.
eatwork
|
|
|
|
|
does any1 know how to shutdown, restart, standby, hibernate, or logoff the Windows XP system?
i know its to do with:
shutdown(*)
* = number corresponding to shutdown type...
i dont know how to perform these tasks... can any1 help me?
thanks...
Adam Forbes
|
|
|
|
|
I would think that you can not do this from an application.It seems to me that it would be too much of a security risk, but if you find out how let me know.
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|
It is possible - but you have to PInvoke native functions in Windows to achieve it.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
You'll have to pInvoke the ExitWindowsEx[^] function in the Win32 API.
Here in an example[^].
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
It's not a security risk. If the logged in user doesn't have the rights to shutdown Windows, it won't happen.
Declare Function ExitWindowsEx Lib "user32" ( _
ByVal uFlags As EWX_UFLAGS, _
ByVal dwReason As EWX_REASON) As Boolean
Public Enum EWX_UFLAGS As Integer
LogOff = &H0
Shutdown = &H1
Reboot = &H2
Force = &H4
PowerOff = &H8
ForceIfHung = &H10
End Enum
Public Enum EWX_REASON As Integer
MajorApplication = 0x00040000
MajorHardware = 0x00010000
MajorLegacyApi = 0x00070000
MajorOperatingSystem = 0x00020000
MajorOther = 0x00000000
MajorPower = 0x00060000
MajorSoftware = 0x00030000
MajorSystem = 0x00050000
MinorBlueScreen = 0x0000000F
MinorCordUnplugged = 0x0000000b
MinorDisk = 0x00000007
MinorEnvironment = 0x0000000c
MinorHardwareDriver = 0x0000000d
MinorHotfix = 0x00000011
MinorHung = 0x00000005
MinorInstallation = 0x00000002
MinorMaintenance = 0x00000001
MinorMMC = 0x00000019
MinorNetworkConnectivity = 0x00000014
MinorNetworkCard = 0x00000009
MinorOther = 0x00000000
MinorOtherDriver = 0x0000000e
MinorPowerSupply = 0x0000000a
MinorProcessor = 0x00000008
MinorReconfig = 0x00000004
MinorSecurity = 0x00000013
MinorSecurityFix = 0x00000012
MinorSecurityFixUninstall = 0x00000018
MinorServicePack = 0x00000010
MinorServicePackUninstall = 0x00000016
MinorTermSrv = 0x00000020
MinorUnstable = 0x00000006
MinorUpgrade = 0x00000003
MinorWMI = 0x00000015
FlagUserDefined = 0x40000000
FlagPlanned = 0x80000000
End Enum
I haven't tested this particular code because it was written from memory and pieces copied from PInvoke.net. To call this:
ExitWindowsEx( EWX_UFLAGS.PowerOff, EWX_REASON.MajorSystem Or EWX.MinorOther)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm creating a small room reservation program in which the user can reserve a room number for a certain amount of time on a certain date.
Let's say room 2 is reserved on 3-3-2006 between 7:00 and 11:00. How can I prevent users from placing a reservation with a starting time, or an ending time, between 7 and 11? They shouldn't be allowed to make a reservation from 8:00 till 9:00, neither should they from 10:00 till 12:00.
I've tried everything, but I have no clue. The only thing I have so far is code that checks whether an exact record exists. So if someone already reserved room 2 on 3-3-2006 at 7:00 till 11:00, an error will show.
I've tried something like this:
SELECT StartTime, EndTime, Date, Comment, Room, PersonID, ID<br />
FROM tblReserveringen<br />
WHERE (StartTime BETWEEN '13:00' AND '14:00') AND (Room= ?) AND (Date= ?)<br />
OR (EndTime BETWEEN '13:00' AND '14:00') AND (Room= ?) AND (Date= ?)<br />
As you can see, I tried to work with parameters. When a record matching the conditions is found, the submission is cancelled. Now if only I could make those time cells variable with parameters, like the rest of -em! Something like:
SELECT StartTime, EndTime, Date, Comment, Room, PersonID, ID<br />
FROM tblReserveringen<br />
WHERE (StartTime BETWEEN (StartTime= ?) AND (EndTime= ?)) AND (Room= ?) AND (Date= ?)<br />
OR (EndTime BETWEEN (StartTime= ?) AND (EndTime= ?)) AND (Room= ?) AND (Date= ?)<br />
Unfortuately, above code does not work (the first example does). Is it even possible what I want?
Any help is greatly appreciated.
--Erwin
|
|
|
|
|
Hi!
Can you loop enum elements?
Ex:
<br />
public enum eSize<br />
Small<br />
Medium<br />
Large<br />
end enum<br />
<br />
For each vSize as eSize in eSize.Elements<br />
DoStuff(vSize)<br />
next<br />
<br />
-- modified at 8:40 Monday 9th January, 2006
|
|
|
|