|
Would that be the hypothetical zee-axis?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
I have an Image. I wanted a perticular part of that image of know dimensions that is the Rectangle is know.
Can some one tell me how to get this perticular part of the Image.
Cheers
|
|
|
|
|
|
You can also use Bitmap.Clone. It lay you specify a rectangle, which is the part of the image.
With Clone, the resulting image will keep the PixelFormat of the source. For instance, if your first image is 8 bits per pixel, indexed, the cloned image will be also.
If you use the other method, with DrawImage, the image must be at least 16bpp I think.
|
|
|
|
|
My project is now to parse the Select SQL String typed by the user to visualize the table, the relation ship, the type of JOIN, the Critical etc... in a form. Would you please give me some hints or some algorithms or tell me if there would an OCX solved this problem? I tried my best to solve this problem but it's too complicated. In MS SQL Server, the SQL string is parsed that is different from the SQL string parsed in MS Access. Thank you.
PS: Actually, there are too many keywords in one SQL string, especially after FROM in the SQL string. And I don't care 'bout what databse is.
|
|
|
|
|
I have a PatientInfo class with some properties (Name, Id, ...), I also have a PatientPrescriptionInfo class that is derived from PatientInfo and as an extra property (PrescriptionCount).
Now I want to cast a PatientInfo object to a PatientPrescriptionInfo object but at runtime I get an 'System.InvalidCastException' exception. How can I solve this? How can I convert a PatientInfo to PatientPrescriptionInfo?
|
|
|
|
|
Unless I am mistaken, you've got the relationship backwards: You can cast the derived class as the parent class (your PatientPrescriptionInfo can be cast as a PatientInfo) but not the other way around.
|
|
|
|
|
Hello,
I'd like to delete file from remote server on client-side. Remote objects are accesed on client using interface, but i don't know which method use to call them.
thanks in advance
|
|
|
|
|
You could do it by getting a proxy to a System.IO.FileInfo object on the client representing the file on the server, then call the Delete() method on that FileInfo object.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
I have a question about the Mem Usage column of the Processes tab of the Windows Task Manager. It seems like any application I write (c#, MFC, whatever) every control (window) event or new form will cause the Mem Usage to go up a little bit. The strange thing is that the Usage rarely releases the same amount as it incremented moments earlier. I don't get it, I create and show a User Control, and I dispose it, and the Mem Usage claims my application is eating up a higher level of resources. Should I be concerned that my application is not releasing resources? How accurate is this Mem Usage thing? A few hundred K every couple of minutes doesn't seem terrible, but if my application is open for hours (which it will be) then by the end of the day, it'll be using a lot of resources (and probably run pretty slow). Some info on this, and how I could possibly identify any problems might be helpful...thanks!
|
|
|
|
|
The TaskManager is not exactly the most accurate method of measuring how much memory your app is using. Use Performance Monitor instead. You can get more accurate metrics and monitor things such as when the Garbage Collector runs and how much memory if freed.
But, don't worry, you're not going to run out of memory. Just because you Disposed an object, doesn't mean that it's freed from memory at that instant. Dispose tells an object to clean up it's resources in preparation for being destroyed. When you call Dispose, the object closes any connections, handles, frees any memory that it allocated, or whatever. The object is then orphaned, meaning that no code can reference that object. The garbage collector, on it's own schedule, then scans the memory space of your app and destroys and frees up memory when it detects an orphaned object. This can take a while if your system has lots of memory available or more frequently as system resources and memory dwindle.
RageInTheMachine9532
|
|
|
|
|
Thank you, this is exactly what I was hoping to hear. Your post was very helpful!
|
|
|
|
|
While the task mgr isn't the greatest performance monitor, it will indicate at least when memory goes up or down. Keep in mind that an operating system's job is to dish out memory when allocation requests come in. It WILL know how much is being given to an application because the OS is what's giving the application working memory.
One thing about forms, though, you need to dispose of them if you ever display a modal dialog via ShowDialog . A simple way of doing this is like:
using (MyForm form = new MyForm())
{
myForm.ShowDialog();
} This disposes native handles (memory addresses) that the CLR does not manage, which is why you keep seeing your memory go up and up when you open new forms. You can also do this modeless forms (via Show ), but it's not necessary.
Basically, any type that implements IDisposable and uses native handles (like FileIOStream ) should be disposed when you're done using it. With System.Windows.Forms.Control you typically don't need to as it cleans up itself pretty well, but disposing it wouldn't hurt when you're done.
It all comes down the CLR and the garbage collector. The reason .NET languages are also call managed languages is because they're managed by the CLR. But native handles aren't managed by the CLR, so you need to make sure that they're "clean-up" (i.e., native resources are released).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I've found a very strange problem and I badly need a fix for it.
I have a simple interface defined in one class library, let's say WindowsLibrary1:
[code]
namespace WindowsLibrary1
{
public interface ITest
{
void Test();
}
}
[/code]
I reference this class library from another project that is a WindowsApplication, lets say: WindowsApplication1.
In the WindowsApplication1 I create a simple usercontrol: UserControl1:
[code]
public class UserControl1 : System.Windows.Forms.UserControl, WindowsLibrary1.ITest
{
....
public void Test()
{ // implementation of the WindowsLibrary1.ITest.Test()
}
}
[/code]
Ofcourse all compiles fine, but I can not use this usercontol at all.
Whenever I try to drop the control on a form I get the following error message:
---------------------------
Microsoft Development Environment
---------------------------
The user control 'WindowsApplication3.UserControl1' could not be loaded. Ensure that the library containing the control has been built and a project reference has been made to the library containing the control. If you have changed the name of the user control, close and re-open the control's designer to update the toolbox item.
---------------------------
OK
---------------------------
I badly need this to make it work, so any help is greatly appreciated.
Thanks,
Corneliu.
PS>> Environment: VS.Net 2003, WinXP.
|
|
|
|
|
Sounds like a version problem. With .NET assemblies and the CLR, version numbers are VERY important (unlike version numbers with native DLLs, which are basically there for reference and for decent installers so they don't copy over newer versions).
When you work with multiple projects in a solution, you really should not use automatic versioning, i.e. using an asterisk in the [assembly:AssemblyVersionAttribute] , typically found in your AssemblyInfo.cs file. The problem seems to be that the version your first project is referencing references one version while the component you added to the toolbox is of a different version.
One other way you can help this is to use a project reference instead of an assembly refernece. When you add a reference to your project (right click, Add Reference...), click on the Project tab and add the project that you want to reference. This establishes a build dependency (making sure that any changes in the dependency prompt a rebuild so the referencing assembly has the latest code) and make sure that the assemblies that are referenced are the correct version.
As far as the toolbox goes, don't explicitly add components to it that you develop and are currently developing in the open solution. Third-party controls and controls that you've build stables version of and deployed should be used there.
VS.NET - though not all the time - will automatically add a reference to any UserControl that you open in the VS.NET designer to the toolbox. If it doesn't, switch to code view, define your field, and instantiate it in the InitializeComponent method that the designer uses. This will make sure it can be designed if you need that sort of thing. You can then continue setting properties and adding event handlers like you normally would on a control using the designer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the answer. Unfortunatelly it does not help as none of your recomandations apply.
I've already tried most of them before posting the question.
I have the feeling that something has happend with my VS.Net after I've un-intalled some addin (I think it was ReShape or something like that). Since then VS behaves sometimes strange. I've just discovered that my example works perfectly on another sistem, thus I think I'll spend my day with reinstalling VS.Net with the hope that this will solve my problem.
Thanks alot,
Corneliu.
|
|
|
|
|
I get an exception in the last line, ExecuteNonQuery. It tells me there is something wrong with the SQL command, although this same command works fine within Access. I have tried this code with insert instead and it works.
myConnection = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=alfapet.mdb");
myConnection.Open();
using(myConnection)
{
OleDbCommand com = new OleDbCommand( "UPDATE userinfo SET Password='"+newPass.Pass+"' WHERE Name='"+user.Name+"' AND Password='"+oldPass.Pass+"'", myConnection);
int i=com.ExecuteNonQuery();
|
|
|
|
|
The way you're doing it is not optimal and often leads to problems because certain characters - like quotes - are not escaped properly. See the documentation for the OleDbParameter class and use a paramterized query like so:
OleDbCommand cmd = myConnection.CreateCommand();
cmd.CommandText = "UPDATE userinfo SET Password=? WHERE " +
"Name=? AND Password=?";
cmd.Parameters.Add("NewPassword", OleDbType.VarWChar, 40).Value = newPassword;
cmd.Parameters.Add("Name", OleDbType.VarWChar, 40).Value = user.Name;
cmd.Parameters.Add("OlePassword", OleDbType.VarWChar, 40).Value = oldPassword;
int i = cmd.ExecuteNonQuery();
Console.WriteLine("{0} record(s) modified", i); The OLE DB provider for ADO.NET does not use named parameters, and instead uses positional parameters using the question mark, so you must add your parameters in the same order. The example aboves assumes you declare your fields as Text using 40 characters as the length. This is just an example, though, so read the documentation for the OleDbParameter for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi there,
How can i dynamically read :-Othe SMTPSERVER NAME from my local network.
hai, feel free to contact.
Sreejith SS Nair
sreejithssnair@hotmail.com
|
|
|
|
|
The only method I know of is to search a range of IP addresses by 1) pinging the address to see if it's alive, then 2) try opening a connection to port 25 on that address. If you get response, you've probably found the SMTP server. Most telecom guys will come down and beat on you for port scanning their network though...
SMTP servers don't "advertise" their presence on the network, so scanning for it the only method to find one automatically.
The better option is to ask the user what the DNS name of the server is or set it in a configuration file.
RageInTheMachine9532
|
|
|
|
|
How to get the IP of SqlServer?
Can you help me?
Jiw
|
|
|
|
|
I'm curious as to why you want the IP address of the SQL Server.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Because i want to copy files to server,but i don't know how to get the Path.
|
|
|
|
|
Getting the IP of the Server will not get you the path... The IP and ServerName are completely interchangable in paths:
\\xxx.xxx.xxx.xxx\share\dir\dir\dir\file
is exactly the same as:
\\servername\share\dir\dir\dir\file
since the system will resolve the servername to it's IP address for you, automatically...
RageInTheMachine9532
|
|
|
|
|
If you know the host name already, you can use Dns.GetHostByName to get the IPHostEntry , from which you can get the IP address. You really don't need it for ADO.NET, though. Just use the SQL Server name and instance (if any besides the default instance).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|