|
i am developing a SDI application.
i have to exit application from other class than Foem class.
how can i do it?
i wrote Application.Exit() in that class, but its not working..
can any body help pls
|
|
|
|
|
If you have other threads running, make sure to stop those as well.
|
|
|
|
|
you can try
Me.Close()
friendship.le
|
|
|
|
|
Hi all,
I have created an object, which is quite large, but very simple, to represent a business document. All well and good...
...but what I'm not too sure about is how to make this object aware of databases.
I've read a few beginners guides on accessing Sql Server from C#, but most of these seem to concentrate on using Data Adapters and what not to display records in a datagrid, via a recordset.
So the question is, how would I go about retrieving a collection of myBusinessDocuments from a database, and display those in a DataGrid and enabling updating, deleting, creating, rather than just returning a recordset and displaying that in a datagrid?
Any help, pointers to articles, impatient sighs greatly appreciated
-- modified at 15:24 Thursday 18th May, 2006
(Oh, if it makes a difference I'm using C# 2.0 and SQLServer 2005)
|
|
|
|
|
I think that's one of the ongoing topics of language research.
You could serialize a class and send it up to the database as a binary, but that's probably not good.
LINQ[^](C# 3.0) is a step in the right direction. You can get the May beta here[^].
Until that's finalized though I think you have to sorta live with SQL queries and ADO.
|
|
|
|
|
Interesting reading there, so I guess the next question is how do folks commonly do this type of task at the moment?
I imagine there's an awful lot of business objects out there in n tier applications, which must need to be persisted to a database at some point. Any idea how they integrate these with ADO.Net (and what would the UML diagram look like)?
Cheers,
Martin.
|
|
|
|
|
To be honest, I'm not too sure.
When it comes to networking and databases I grew up in the Unix environment, and the style there is quite different -- not too much OOP, not too much architectural consideration. Most of the code I saw was just raw SQL queries. Things are really down to earth, not that that's necessarily a good thing.
My experience with ADO.NET hasn't been too good; it's one of the few things that really bothers me about .NET, though that's apparently what LINQ is trying to change. The idea is quite intuitive, but there's a lot of quirks that you have to get around, and you'll be pulling your hair out if you don't plan things carefully.
I'd probably just work with SQL queries encapsulated by business objects that do all the logic and sanity checks. You have to be extra careful especially with security (watch out for SQL source injection[^]), but it's a lot easier to know what's going on.
Here's a pretty good guide on System.Data in case you decide to go that route: http://www.codeproject.com/csharp/practicalguidedatagrids1.asp[^]
|
|
|
|
|
Again, some interesting articles there
I've done some more digging around on this, and it looks as if Data Access Layer is what's called for here... possibly!
Here's what seems to be a good article on the subject: http://msdn.microsoft.com/msdnmag/issues/03/04/DataAccessLayer/
To my mind, and from what I understand of the subject so far, the controls and types povided by MS (DataGrid, DataSet etc. etc.) are simply one type of Data Access Layer, back-ended by ADO.Net - and given the right level of skill, knowledge and know how (not to mention time) it should be possible to work the same kind of magic with your own classes and what not.
I'm sure all the tools are there to enable this, but it does seem to me that it would involve a lot of monkey work, developing frameworks etc - maybe I'm wrong, or maybe this is what LINQ will solve. Further investigation on going
(I also hear that Ray Lohkta's book C# Business Objects covers this subject as well, but I think it's probably beyond my grasp at the moment... I'm just getting to grips with the concept of design patterns)
Cheers,
Martin.
|
|
|
|
|
It's pretty frustrating just dealing with all of these options, none of which seem to be very concise.
Sorta makes sense that database programmers are among the best paid
Here's[^] another article I found, though you might find it's not too informative.
Good luck with your work!
|
|
|
|
|
Hello. I'm having a problem with focus. I'm developing an application with VS 2005 that is like the Outlook mail notification. I have a NotifyIcon and at a time a winform appear. The problem is that when I'm typing for example a word document and the alert appear I lost the focus to the alert and I can't continue typing my document. I call the window with frmForm.Show();
Thanks a lot !!!
|
|
|
|
|
After you show the alert, you must set the focus back to your form.
this.form1.Focus();
|
|
|
|
|
hi guys, is there anyway i can cast a string
like "System.UI.Button" to a Button?
thanks
|
|
|
|
|
You can create a type from a string with Type.GetType(typeName)[^], if that's what you mean.
Otherwise, since you can't exactly cast a type specifier into an instance, a little more info would be useful.
--
I've killed again, haven't I?
|
|
|
|
|
Activator.CreateInstance[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
if I have an array of 32 byte for example.
but there's only 8 slots used.
How can i count the number of slots used.
.length() or .getlength(0) only give me the total size of the array.
Thank ya'll
Donkaiser
|
|
|
|
|
Depending on what you fill into it there is probably no way. Better would probably be to use an ArrayList instead which handles this internally.
Other than that you could for example use Array.IndexOf(null) to find the first not assigned index. But this will only work if the type of the array is not a primitive type or structure.
|
|
|
|
|
try to create your own function... eg.
public int NumUsed(Byte[] arr)
{
int Ctr = 0;
for (int i = 0; i < arr.GetLength(0); i++)
{
try
{
Byte tmp = arr[i];
Ctr++;
}
}
}
although i'm not pretty sure that this will work... but you can try.
|
|
|
|
|
There are 2 problems with this approach
1) You cant have a try without a catch or finally.
2) Exception's should not control the flow of a program.
You are better off using an ArrayList or some type of collection, as they usually resize internally asnd provide a Count property.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
You are totally wrong. There are even more problems
3) the return statement is missing
4) even a call like NumUsed(new Byte[100]) (nothing set in the array - just initialized) will result in 100
|
|
|
|
|
that's why i said I'm not sure it'll work...
|
|
|
|
|
So now you can be sure it'll not work
|
|
|
|
|
why instead don't you try
won't it work???
public int NumUsed(object[] arr)
{
int Ctr = 0;
for (int i = 0; i < arr.GetLength(0); i++)
{
if( arr[i]!=null)
Ctr++;
}
return Ctr;
}
and when you set one array position to unused do it like
arr[i] = null
of course you would have to use an object array but you could cast the object to byte when you
the real value
i think it will do
NOthing by now;)
|
|
|
|
|
pq4noeh wrote: of course you would have to use an object array
But where the heck would then be any reason not to use an ArrayList?
|
|
|
|
|
Use a List<> and read the .Count value.
|
|
|
|
|
An array doesn't have a concept of unused items. When you create the array all the items are initialized to their default value, for bytes that is zero. So all items are initialized, used, and have valid values.
Either you have to define a special value that means that the item is unused, so that you can test each value, or you have to keep track of which items are used using another variable or array.
Or use a list instead.
---
b { font-weight: normal; }
|
|
|
|