|
Please remember to properly format the code you post using the pre tags, i.e. the "code block" menu item above the textbox. Many people will not read or answer a post that does not follow the guidelines that have been clearly posted here.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
FWIW: I've never used ComponentDispatcher nor its ThreadPreprocessMessage, maybe this is a WPF app? For a WinForm, I would use a visible Form (possibly off-screen, i.e. with fake Location) and override its WndProc. And then the app needs to run as administrator on Vista/Win7 for the (un)RegisterHotKey to work properly.
|
|
|
|
|
hi
i have C# Winform program and i need to convert it to Webform.
can i get any simple sample for how to show database grid on screen,
add new, update and delete ?
i try to show table on screen like this:
SQL = "SELECT * FROM MEN order by Lname";
dsView = new DataSet();
adp = new SqlDataAdapter(SQL, Conn);
adp.Fill(dsView, "MEN");
adp.Dispose();
GridView1.DataSource = dsView.Tables["MEN"].DefaultView;
but i dont see nothing
|
|
|
|
|
Don't cross post. Read the forum guidelines and pick one forum.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Is there a library to
-read/stream MP3
- detect beats per minute
- create a mix between 2 different MP3/Wav
|
|
|
|
|
hi
i have Winform program that connect to sql-server-2008
there is 100 user's that connect to this database and
run search query --> and update the database.
i open the connection when the program start's and close when the program end's.
is this the right thing to do ?
is it be better to open connection -> run query -> update -> and close connection ?
thank's in advance
|
|
|
|
|
Have a look at this[^]. I'm sure it will help you.
|
|
|
|
|
Absolutely: Open connection, query, close and dispose.
Database connections are a scarce resource, do not hog them or you will make your DB admin very annoyed...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
It's best to open and close connections on the fly. Under the covers, .NET manages a pool of connections so opening and closing connections is cheap and managed for free. You can take control of this pool if you want.
|
|
|
|
|
Plus, I hope you don't have data access in the UI layer.
|
|
|
|
|
My rule of thumb is to leave a connection open the shortest time possible. Open, query, update, close.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Navigate the Give Link to know best practices of Using Connection.
best practices[^]
|
|
|
|
|
Hi C# Guru's,
i have recently written a command line C# app that uses psexec to run Netstat on remote machines and sends the results to a text file, it works ok...ish.
firstly, even though i have set the process to psi.UseShellExecute = false and psi.CreateNoWindow = true it still pops up a command window - any idea how i stop this?
secondly, even though it sends most of the output to the text file it cuts it off short, i have used the below code TNA.
while(p.StandardOutput.EndOfStream == false)
{
sw.Write(p.StandardOutput.ReadToEnd());
p.WaitForExit();
sw.Flush();
}
the bottom part of the output file looks like:
TCP 172.17.134.138:80 172.17.134.133:51076 TIME_WAIT 0
TCP 172.17.134.138:80 172.17.134.133:52450 TIME_WAIT 0
TCP 172.17.134.138:80 1
any ideas on how to get the full output?
Many Thanks,
Phil
|
|
|
|
|
Hi,
your code looks only so so, with a loop, several ReadToEnd and a flush.
assuming you save all incoming text to a file, there is no need to catch it while the netstat app is still running, so simplify your code to first wait for netstat to exit, then wait 500 msec to make sure everything has settled, then just once read all its output; assuming you close the output stream (or use a using statement) there is no need to flush either.
|
|
|
|
|
Hi,
thanks for post. i'm still a beginner at this...
how would i do what you suggested?
many thanks,
Phil
|
|
|
|
|
p.WaitForExit();
Thread.Sleep(500);
string s=p.StandardOutput.ReadToEnd();
File.WriteAllText(filepath, s);
|
|
|
|
|
Hi Luc,
thanks for your speedy reply.... it still doesn't work!
i still get the same result, it cuts of some of the output.
when i run psexec manually it does give some output and then pauses for the server to reply with more data. i think this is the point where it cuts out.
i'm open for any more suggestions!
many thanks,
Phil
|
|
|
|
|
is it repeatable, i.e. does it always produce the exact same output?
if so, can you show the output?
could it be that the target app launches yet another app, whose output is exactly what gets lost?
|
|
|
|
|
hi,
yes, the output is always the same.
this is the output:
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:80 0.0.0.0 LISTENING 4
TCP 0.0.0.0:135 0.0.0.0 LISTENING 688
TCP 0.0.0.0:445 0.0.0.0 LISTENING 4
TCP 0.0.0.0:3389 0.0.0.0 LISTENING 1156
TCP 0.0.0.0:49152 0.0.0.0 LISTENING 392
TCP 0.0.0.0:49153 0.0.0.0 LISTENING 872
TCP 0.0.0.0:49154 0.0.0.0 LISTENING 928
TCP 0.0.0.0:49155 0.0.0.0 LISTENING 496
TCP 0.0.0.0:49157 0.0.0.0 LISTENING 1280
TCP 0.0.0.0:66258 0.0.0.0 LISTENING 488
TCP 172.22.139.171:139 0.0.0.0 LISTENING 4
TCP 172.22.139.171:50362 172.16.66.85:3389 ESTABLISHED 7296
TCP 172.22.139.171:50774 172.16.66.85:389 CLOSE_WAIT 4984
TCP 172.22.139.171:50962 172.16.65.75:2020 ESTABLISHED 2304
TCP 172.22.139.171:51323 172.16.66.136:2528 ESTABLISHED 2536
TCP 172.22.139.171:51377 194.34.15.37:139 ESTABLISHED 4
TCP 172.22.139.171:51523 172.16.66.86:135 TIME_WAIT 0
TCP 172.22.139.171:51527 172.16.66.86:139 TIME_WAIT 0
TCP 172.22.139.171:51530 172.16.66.89:135 TIME_WAIT 0
TCP 172.22.139.171:51536 172.16.66.89:139 TIME_WAIT 0
TCP 172.22.139.171:51539 172.16.66.86:135 ESTABLISHED 688
TCP 172.22.139.171:51540 172.16.66.86:2007 ESTABLISHED 4132
TCP 172.22.139.171:51543 172.16.66.86:139 ESTABLISHED 4
TCP 172.22.139.171:58467 172.16.66.86:1025 ESTABLISHED 2536
TCP 172.22.139.171:60942 172.16.66.85:1025 ESTABLISHED 476
TCP 172.22.139.171:60945 172.16.66.85:1025 ESTABLISHED 2536
TCP 172.22.139.171:61196 172.16.227.140:139 ESTABLISHED 4
TCP 172.22.139.171:62671 172.16.66.92:139 ESTABLISHED 4
TCP 172.22.139.171:66301 172.16.160.12:5061 ESTABLISHED 476
TCP 172.22.139.171:66322 172.16.130.91:4204 ESTABLISHED 2536
TCP 172.22.139.171:66586 172.16.66.85:389 CLOSE_WAIT 4984
TCP 172.22.139.171:66923 172.16.194.31:139 ESTABLISHED 4
TCP 172.22.139.171:65420 172.16.66.85:389 CLOSE_WAIT 4984
TCP 172.22.139.171:65480 172.16.66.85:389 CLOSE_WAIT 4984
TCP [::]:80 [::] LISTENING 4
TCP [::]:135 [::] LISTENING 688
TCP [::]:445 [::] LISTENING 4
TCP [::]:3389 [::] LISTENING 1156
TCP [::]:49152 [::] LISTENING 392
TCP [::]:49153 [::] LISTENING 872
TCP [::]:49154 [::] LISTENING 928
TCP [::]:49155 [::] LISTENING 496
TCP [::]:49157 [::] LISTENING 1280
TCP [::]:66258 [::] LISTENING 488
TCP [::1]:445 [::1]:51544 ESTABLISHED 4
TCP [::1]:51544 [::1]:445 ESTABLISHED 4
UDP 0.0.0.0:123 *:* 1056
UDP 0.0.0.0:500 *:* 928
UDP 0.0.0.0:4500 *:* 928
UDP 0.0.0.0:5355 *:* 1156
UDP 0.0.0.0:6004 *:* 2536
UDP 127.0.0.1:54417 *:* 2536
UDP 127.0.0.1:55932 *:*
|
|
|
|
|
Hi All,
Is there any way to know what is my public IP??
example say my public IP is 202.214.215.12
How would I know my IP??
Please dont say ipconfig.
Thanks,
Sunil G.
|
|
|
|
|
Yes, there is a way, you could ask your NAT device what its (and therefore also your) public IP address is.
|
|
|
|
|
Can u give me some idea how to do it??
|
|
|
|
|
Hi,
you could use UPnP of your router
bye
|
|
|
|
|
MonoTorrent can do it (UPnP and NAT-PMP), Windows has stuff for this build-in as well but it's not very reliable (IIRC it depends on a service which can be disabled), and you could read my article (it's a little old though)
|
|
|
|
|
Try a Google search, there are quite a few sites that can find this information for you. I think one of them may even be called "whatsmyip.com".
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|