|
Hi, I think that he was mean system namespase because there is not systen class in .NET
|
|
|
|
|
Hello
I have a very difficult problem to explain. I have a password dialog box so that people can change there password. The dialog box will request for their current password, anc check that is is valid. Then request them to enter their new password and then re-enter their new password. The passwords are checked using the tab button when they leave a text box on the (leave event). When they have done all this they click the ok button and the new password is set. If however, they cancel using the cancel button. Then the dialog box will not close. This is the code below so you can better understand my problem.
This is the code for when the user enters the password, and presses the tab key to go to the next text box. When this event fires it will check the password is correct. Enter new password and re-enter password uses the same idea. I will not post it here as the code is the same.
<br />
private void txtEnterPassword_Leave(object sender, System.EventArgs e)<br />
{<br />
string queryValidatePwd = "SELECT Username, Password FROM AdminUsers WHERE Username = '" + lblLoginName.Text + "' AND Password = '" + txtEnterPassword.Text + "' ";<br />
<br />
try<br />
{<br />
OleDbCommand cmdValidatePwd = cnnChangePassword.CreateCommand();<br />
cmdValidatePwd.CommandType = CommandType.Text;<br />
cmdValidatePwd.CommandText = queryValidatePwd;<br />
<br />
OleDbDataAdapter daValidatePwd = new OleDbDataAdapter(cmdValidatePwd);<br />
DataTable dtValidatePwd = new DataTable("AdminUsers");<br />
<br />
int count = daValidatePwd.Fill(dtValidatePwd);<br />
if ( daValidatePwd.Fill(dtValidatePwd) == 1 )
{<br />
txtEnterNewPassword.Visible = true;<br />
txtEnterNewPassword.Focus();
}<br />
else<br />
{<br />
MessageBox.Show("Password is incorrect for this username - please try again","Incorrect Password",MessageBoxButtons.OK,MessageBoxIcon.Warning);<br />
txtEnterPassword.Clear();<br />
txtEnterPassword.Focus();<br />
}<br />
dtValidatePwd.Dispose();<br />
daValidatePwd.Dispose(); <br />
}<br />
catch ( OleDbException ex )<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
catch ( Exception ex )<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
Code for when the user closes the dialog box. The the other textboxes have focus you cannot close this form. I have tired using this.close() as well, but still does not work.
<br />
private void btnCancel_Click(object sender, System.EventArgs e)<br />
{<br />
this.Dispose();<br />
}<br />
Thanks for you help in advance,
Steve
|
|
|
|
|
Your code looks fine to me, perhaps you should use the Close procedure to close your window. You say that the windows doesn't close so as odd as this may sound, but you should check all the events you handle, maby one of them is stopping you from closing your form.
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
In Click event handler for your Cancel Button , if you showed the form with ShowDialog (a modal dialog), try:
DialogResult = DialogResult.Cancel That should work.
Otherwise, call Hide if you created a modeless dialog (Form.Show ).
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Did you try setting the CancelButton property on the form to your Cancel button?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
HI,
how to use win32 datatype in c#.NET
am using
[DllImport("Kernel32", CharSet=CharSet.Auto)]
private unsafe static extern UInt32 CreateIoCompletionPort(UInt32 hFile, UInt32 hExistingCompletionPort, UInt32* puiCompletionKey, UInt32 uiNumberOfConcurrentThreads);
this function , n i wants to pass a socket to ist parameter as a handle
and when i convert socket to UInt32 it gives me
INVALID CAST EXCEPTION
so how i pass socket to UInt32 hFile this argument.???
please help me ...........
Thanks
babur.saeed@gmail.com
its_me_babar@yahoo.com
Babar
|
|
|
|
|
Handle dataTypes in C# must be IntPtr, therefor you procedure should look like this :
[DllImport("Kernel32")]
private static extern IntPtr CreateIoCompletionPort(IntPtr hFile, IntPtr hExistingCompletionPort, IntPtr puiCompletionKey, IntPtr uiNumberOfConcurrentThreads);
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Thank u very much i have solved the problem,,,,,,,,
but now stuck into another problem
can u help me if i send u code?
|
|
|
|
|
|
Hi,
when i create a software with c# for different OS, do i need to compile the source code on every computers with destination OS, i mean, i create a project on winxp, but i wont that is runnable on windows2000 to, do i must to compile the project on win2000 first befor a create a release? I hope that my question is understandable!
thanx
mirsad
|
|
|
|
|
Hi!
No, you don't have to compile for every OS.
There are, however, some classes in the .NET framework that are not supported on every OS .NET runs on (for example, a FileSystemWatcher only is available on NT-based systems: NT, 2000, XP, 2003).
The framework documentation tells you which OS's a class is supported on.
mav
|
|
|
|
|
No.
Just like Java, C#/.NET-FW means: compile once, run anywhere.
There are, however, a few drawbacks:
In order to run an application on a target system, the target system must have a .NET-Framework installed.
There also IS a difference between v1.0 and v1.1 Applications (i.e. Applications for the .NET-FW Version 1.0 and .NET-FW Version 1.1), so take that into consideration.
AFAIR, there is no .NET FW available for Win95, which might or might not be a problem.
Last drawback: The Microsoft .NET Framework is only available for "Wintel", AFAIK. You might have to use MONO as the executing framework instead, which is available at www.go-mono.com (read the corresponding article here on CP).
That should have been all
Cheers
Sid
|
|
|
|
|
good answer.
If you copied that response to notepad, you could use it 100+ times a day on these forums.
|
|
|
|
|
heh, actually I was thinking aboout kind of browser plugin... like code snippets in VS.NET 2k5, but with common links to MSDN, Colin's SQL Injection article etc. You know, things you keep writing again and again. Unfortunately I don't know how to do IE/FF plugin and I don't have much time to learn...
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
hi,
thanx to all for answers, i create nice tool with c#(with help of course), but they dont work on win2000, on WinXP is no problems! That is the problem what i have, and i am beginner in this, the error message is when i start this tool after installation on Win2000 follow:
Enable JIT-Debugging in the section: system.windows.forms !
This is a ATL tool with hook's, and inplemented a cmd.exe in the Window Explorer if you want, for example, you dont need to start the console explicit, only press a key, example alt + m !
But thanx for help
mirsad
|
|
|
|
|
Perhaps your application wont run on an other system (which I assusme it has .Net framework installed) because you use Platform Invokes, meaning that your program is based on a specific platform and/or why not on a specific application.
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
I have created folders in Outlook programmatically. Whne i add mail items to it programmatically and try double clicking them in Outlook to open them, instead of opening the message a compose window is opened. Can some body tell me how can I solve this problem.
|
|
|
|
|
Hello....
Please, can you tell me how to limit the time for a user when using the Internet Service as an administrator. Using ADSI and C# languges; because I want to build an ISP phone based company. In addition to that, is there an Instruction to see if the user account locked or not?
Thanks a lot....
|
|
|
|
|
Hi to all
i m new to C#.. can anyone plz help me to read a text file in parts... sample is below..
05-02-14 33 1 2 11 ORIS 2569874
i have used the ReadLine() function to read a line but how i can parse the following format in separate fields.Plz help me in this regard.... thanks
|
|
|
|
|
Hi,
You can use the parsing functions in string, like Split, IndexOf etc.. To parse each item in your string, assuming they are separated by space, you can do
<br />
string lineRead = streamReader.ReadLine();<br />
string []arr = lineRead.Split(" ");<br />
For converting a string to an int, you can use the Int32.Parse method.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello fellow C# friends,
I am trying to write a C# TCP client that was formerly written in Java.
The server must still remain in Java.
I cannot get text data from the C# client to be received by the Java
TCP server. No matter how I try to send data from the client to the
server, the Java server DataInputStream readUTF() method never returns
with any data. Can someone please shed some light on this problem?
Thanks.
-Frank
I re-wrote them both in simpler form for demonstration purposes.
Java Based Server:
----------------------
import java.net.*;
import java.io.*;
import java.util.*;
public class ChatServer {
public ChatServer (int port) throws IOException {
ServerSocket server = new ServerSocket (port);
while (true) {
Socket client = server.accept ();
System.out.println ("Accepted from " + client.getInetAddress ());
ChatHandler c = new ChatHandler (client);
c.start ();
}
}
public static void main (String args[]) throws IOException {
new ChatServer (1098);
}
}
import java.net.*;
import java.io.*;
import java.util.*;
public class ChatHandler extends Thread {
protected Socket s;
protected DataInputStream i;
protected DataOutputStream o;
public ChatHandler (Socket s) throws IOException {
this.s = s;
i = new DataInputStream (new BufferedInputStream
(s.getInputStream()));
o = new DataOutputStream (new BufferedOutputStream
(s.getOutputStream()));
}
protected static Vector handlers = new Vector ();
public void run () {
String name = s.getInetAddress ().toString ();
try {
System.out.println(name + " has joined.");
handlers.addElement (this);
while (true) {
System.out.println("Waiting for data...");
String msg = i.readUTF ();
System.out.println(name + " - " + msg);
}
} catch (IOException ex) {
ex.printStackTrace ();
} finally {
handlers.removeElement (this);
System.out.println(name + " has left.");
try {
s.close ();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
C# Client
----------------------
using System;
using System.Threading;
using System.Net.Sockets;
using System.IO;
using System.Data;
using System.Net;
using System.Text;
namespace TCPClient
{
class Client
{
static NetworkStream output;
static BinaryWriter writer;
static BinaryReader reader;
static Thread readThread;
[STAThread]
static void Main(string[] args)
{
string msg;
TcpClient client;
client = new TcpClient();
client.Connect( "localhost", 1098 );
output = client.GetStream();
writer = new BinaryWriter(output, System.Text.Encoding.UTF8);
reader = new BinaryReader(output);
readThread = new Thread(new ThreadStart(RunClient));
readThread.Start();
do
{
Console.Write("Text to send: ");
msg = Console.ReadLine();
if (msg == "")
break;
Byte[] byteDateLine = Encoding.ASCII.GetBytes( msg.ToCharArray() );
writer.Write(byteDateLine, byteDateLine.Length, 0 );
} while (true);
Console.WriteLine("Closing connection");
readThread.Abort();
writer.Close();
reader.Close();
output.Close();
client.Close();
}
static void RunClient()
{
string msg;
try
{
Console.WriteLine("Waiting for data from server...");
do
{
msg = reader.ReadString();
Console.WriteLine(msg);
} while (true);
}
catch ( Exception error )
{
Console.WriteLine( error.ToString() );
}
}
}
|
|
|
|
|
Does writer.Flush() after writer.Write() in the client side help?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi!
I'm not really sure if this will help you but I remember having played around with .NET<->Java communication via TCP/IP.
IIRC, the byte-order was different between .NET and Java, so if you write a 4 byte integer value, for example, you'll have to reverse the bytes on the receiver's side to get the correct value.
Could be the case with sending strings as well...
Regards,
mav
|
|
|
|
|
Not sure if that has something to do with your problem, but doesn't JAVA only use Unicode (UTF-16)?
Wouldnt that mean that receiving UTF-8 lead to problems?
Did you try switching the client's encoding to UTF-16 instead?
Cheers
Sid
|
|
|
|
|
What is bothering me is that on the Java server side the DataInputStream readUTF() method remains blocking and never returns, even with improperly formatted data. The Socket connect's and disconnect's are acknowledged though normally.
-Frank
|
|
|
|