|
If I do the following:
DateTime objDOB = null;
...then I get the following error:
Cannot convert null to 'System.DateTime' because it is a value type.
What do you mean by DBNULLs just disappear?
Regards,
ma se
|
|
|
|
|
You need to be using Visual Studio 2005 for this to work, and you need to use nullable types (put a question mark after the type):
DateTime? dob = null;
Then, for instance, when you come to pass the date to Sql Server you could on your SqlCommand use:
command.Parameters.Add("@date", SqlDbType.DateTime).Value = dob;
.. and if dob is null, you'll get a DBNULL in the db.
Regards,
Rob Philpott.
|
|
|
|
|
I want tutorial for using Design Pattern which includes DTO,FACADE,BO,DAO in asp.net(c#).if someone having please send.Thank u.
SRIDHAR
|
|
|
|
|
There are several good books out there GoF (Gang of Four) and many from the Martin Fowler Signature Series from Addison Wesley, but if you are just looking for a website, I might recommend you check out Design Patterns[^].
|
|
|
|
|
How can I change the refresh rate to my monitor in C#? I nee a sample of code. Can somebody help me? Thanks
Da_Masca
|
|
|
|
|
Dear gurus,
I have some beginners question.
Visual Studio has a nice "look and feel" with all the splitters and the tabbed views, docking .....
Is this type of gui available as some framework from microsoft or do I have to program it manually.
Do you have some links for me?
Thank you for your help ! ! ! !
-- modified at 9:36 Tuesday 11th April, 2006
|
|
|
|
|
|
|
The 2.0 version of the .NET Framework includes the ToolStrip family of controls. That will let you give your apps menus and toolbars similar to those in VS 2005. The docking however, is on your own.
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
can any professional tell my how i will dispose my object if i had created class contating various object like Datasets and Database Adapter , i have tried to implement IDisposable interface but when watching my application in Windows Task Manager i see the memory size going bigger time after another untill thrown an exception saying MemoryOut , i have called Dispose method for .NET Object (Datasets and Database Adapters) but it was growing also, my question is how could i dispose my string and integer variable beside my objects in the class immedialtelly and don't wait for the garbage collector ........
agmb
|
|
|
|
|
Include both a Dispose method and a destructor, to make sure that the object is always disposed of:
public void Dispose() {
if (this.myData != null) {
this.myData.Dispose();
this.myData = null;
}
GC.SuppressFinalize(this);
}
~MyClass() {
this.Dispose();
}
The task manager is not suitable for monitoring memory usage for .NET applications. The size reported also includes the unused heap space. You shouldn't get a MemoeryOut exception, though, that indicates that there is some problem.
You only have to dispose of classes that have a Dispose method. Strings are fully managed and doesn't need to be disposed. Integers are value types, so they are not allocated in the heap at all.
The garbage collector manages all the removal of unused objects, and you normally don't need to bother how it does that. Garbage collections are performed when needed, and when it's appropriate. If you run into memory problems, it's rarely the fault of the garbage collector, but more likely a memory leak in the code you are using.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks alot for your description , but suppose there is a memory problem or GC problem , should i reinstall .NET Framework to my machine (WIndows 2000 Server)?
agmb
|
|
|
|
|
Yes, you can try that. I don't really expect it to help, but it will at least elliminate a possible reason for errors.
---
b { font-weight: normal; }
|
|
|
|
|
Hi everyone,
Please help me with this program:
A program to simulate the calculation of 1 + 2 + 3 ...+ 999 +1000.
Use multiple threads to simulate multiple reactions in an array of 1000 elements happening at the same time.
For example, 1 + 2 = 3
4 + 6 = 10
3 + 5 = 8
7 + 9 = 16
8 remaining
and then those numbers continue add each other randomly, the process continues until there is only 1 number left.
Thanks so much
eric
|
|
|
|
|
someone don't want to do their homework on their own ;P;P
|
|
|
|
|
This is the forum so that everyone supposes to discuss together.
This is my assignt actually. I need help.
I try to use Random.Next in multiple arrays and remember the old elements in an separate array.
But I need discussion from anyone who is better than me then.
Thanks
eric
|
|
|
|
|
eric_tran wrote: This is the forum so that everyone supposes to discuss together.
Yes, but school is a place where YOU Learn. If your teacher found you soliciting for answers here i assure you you would be failed.
|
|
|
|
|
Thanks
But this is an open assign, my teacher expects me to do it with any help as long as I understand it.
I didn't let my assignt to someone doing it.
I've been doing it. I just need discussion.
Thanks
eric
|
|
|
|
|
hehe, shurly, but your questions should be more spesific.
First, you need to know how many thread's you have to youse.
Let's asume that you should youse 2 threads.
Use an ArrayList with 1000 records with values from 1 to 1000.
The ArrayList can only be accessed by on thread at a time, so you need a parameter that determen that the
ArrayList is available for accessing.
lets say it is a
bool bIsAccessable = true;
So, the first thread starts, it looks if bIsAccessable is true, if so it sets it to false.
The second thread starts, it looks if bIsAccessable is true, but it isen't so it has to wait,
so now you need a timer, that should hold the thread for some millisecound, and then se if bIsAccessable is true, and so one and so one.
the first thread that know has access to the ArrayList,
gets the length of the ArrayList and creats a 1 random number, with max value of ArrayList.Count (1000)
Get's the rows value, and removes it from the the ArrayList, then
stores the value. Then it should get a new random number, whit max value of ArrayList.Count (that now is 999)
Get's the rows value, and removes the row from the the ArrayList.
Now the first thread can let go of the ArrayList becouse it has it's 2 numbers, so it sets the bIsAccessable to true.
Now the second thread can access the ArrayList, meenwhile the first thread calculates the sum of the 2 values it got.
I think there is a flau in my theory "What if both threads access the bIsAccessable" at the same time?"
So a think you need a thread that takes care of who that can access the ArrayList.
Well this should get you started.
Hope it helps
Thomas
|
|
|
|
|
thomasa wrote: I think there is a flau in my theory "What if both threads access the bIsAccessable" at the same time?"
Yes, there is. The method is fundamentally right, but the flaw is that there is a slight period of time beween checking the value of the flag and setting the flag, where another thread could check the flag and also find it true.
Use the lock keyword to obtain exclusive access to an object:
lock (theList) {<br />
...get values<br />
}<br />
...process values<br />
lock (theList) {<br />
...put the result back<br />
}
---
b { font-weight: normal; }
|
|
|
|
|
Thanks so much Thomas.
This is the advance level of my assignt.
I used 5 threads. My method is similar as yours.
But I've been struggling with the coding.
Hopefuly I can get help later
Eric
eric
|
|
|
|
|
Hi.
I am wondering how one goes about making an application not work after some time. I just made an app and I want it to work for a year and then the buyer needs to buy again. How do I do that? This is similar to how many companies do, they license their software for some time and after some time it stops working or something like that. How is this done?
Thanks,
F
|
|
|
|
|
i don't have professional experience in this matter,
but the first thing that comes up with me , is registering a start date somewhere in registry, and make your application check that date everytime it starts. I would not check the system time, because with putting it back, the program should work again.
Now i'm curious how other people think of this.
|
|
|
|
|
You have to store the date the application was started the first time, then every time the application starts you have to compare todays date with the stored date.
The user can ofcours youst revind the date in his bios, to make the application work again.
Thus, if you the application requirs internett access, you could stor the date on a private server, and compare it with the servers "todays date".
|
|
|
|
|
Hi.
Can you maybe elaborate a little more? Isn´t there some simple way of doing this? I was thinking of DateTime, perhaps creating a thread that checks to see if year is 2007 and then disables something in the program. Do you know how to do this?
Thanks,
F
|
|
|
|