|
darkelv wrote: "select * from tasks where asset_tag = '" + txtAssetTag.Text + "'"
No! NO! NO! NO! NO! NO!!!!
Never advise anyone in any way which would obviously lead to a SQL Injection Attack.
Please read SQL Injection Attacks and Tips on How To Prevent Them[^].
And yes, I know you suggested to use paramerised queries to avoid attack, but your sample should have used that from the off.
|
|
|
|
|
Which is why I suggested him to use the parameter thingie in the end
|
|
|
|
|
All Controls have a Tag property which lets you store custom data.
|
|
|
|
|
Hi
I have a problem while using the Filesystem watcher component in conjunction with a Windows form application.
I'm trying to do the following:
The form should show the content based on af file (which can be modified from another application!) and this should be done dynamically while the form runs...
So what I've done is to add a standard form to the app and then build the form contents dynamically based on the information contained in a file. The form contents is a panel and on that some labels and picture boxes...
So I would like to register a filesystem event monitor to detect when the file changes and re-create the Panels contents dynamically...now the problem occus...!
When trying to update the panel I get an error saying that:
Cross-thread operation not valid : Control 'pnlUpdates' accessed from a thread other than the thread it was created on.
The line of code that causes this error is:
pnlUpdates.Controls.Add(lblTest);
I suppose it is because the filesystem watcher is running in another thread and therefore this is not allowed?? I tried to use a backgroundworker to allow the update but this fails if I start the process from the OnChanged event of the Filesystem eventwatcher (same thread error as above)...
Anyone who knows how this can be done?
Kind regards
Thomas
|
|
|
|
|
Must say I'm chuffed - I figured out the problem by reading just the subject.
I had the same issue in a different context the other day; the problem is that Winforms controls are not thread safe. I'm not at work right now, so I don't have the code, but you will have to use a delegate in your form class to point to the method that actually does the work. In your event handler, you will have to invoke the delegate like
this.Invoke(new YourDelegate(TheMethodThatUpdatesTheControls)); The copy of MSDN on my colleague's machine was very helpful with this. If you're still having problems, just yell and I will give you the code when I get back to work tomorrow.
Cheers,
विक्रम
And sleep will come, it comes to us all
And some will fade and some will fall
|
|
|
|
|
Hi
Thanks a lot for the help. Used the invoke method and it works like a charm!
Kind regards
Thomas
|
|
|
|
|
tsiv wrote: Used the invoke method and it works like a charm!
It's not a charm. The behavior and solution are well documented. If you want to be a software developer rather than a snake charmer I strongly suggest you start reading the documentation.
|
|
|
|
|
Don't you have something better to do than drop stupid comments on this forum!?
Fool.
I had a problem - Vikram was kind enough to point me in the direction of a solution - why do you even bother to give feedback if the feedback isn't worth anything...?? I don't understand that...
Thomas
|
|
|
|
|
tsiv wrote: why do you even bother to give feedback if the feedback isn't worth anything...?? I don't understand that...
Of course you don't get it because you don't comprehend the value of reading the documentation. I can point that out to people like you but I can't make you understand it.
There is an old proverb, once again I can recite it but I can't make you understand it:
“Give a man a fish and you feed him for a day, teach a man to fish, and you feed him for a lifetime.”
|
|
|
|
|
|
You might want to read this article. Hopefully it will clear up a lot of things: http://www.codeproject.com/csharp/begininvoke.asp
|
|
|
|
|
Hello, I'm writing a ALT+TAB-ish app that pops up due to a hotkey. It currently displays a list of currently running applications (using EnumWindows & GetWindowText) as a row in a DataGridView and I've created a event handler to run when a row is double clicked on.
I'm hoping to use SetForeGroundWindow from User32.dll to bring the selected app to the front. This requires a pointer (IntPtr) to be passed, which I have available when populating my grid, but I can't see to keep around in IntPtr format. When I assign the IntPtr to a cell value, and then try to recast it as a pointer again, it bombs:
_hWnd = (IntPtr)dgvTaskList.SelectedRows[0].Cells[2].Value;
SetForegroundWindow(_hWnd);
I need to either
A) store a raw IntPtr in a cell (not as a string)
B) be able to convert the string back to a ptr
C) something else entirely that I'm not thinking of
I'm open to any help or suggestions from my code project peers...
Thanks!
-- modified at 12:13 Tuesday 27th November, 2007
|
|
|
|
|
how about...
_hWnd = new IntPtr(int.Parse(dgvTaskList.SelectedRows[0].Cells[2].Value));
Jeff
|
|
|
|
|
Holy cow man!
_hWnd = new IntPtr(int.Parse(dgvTaskList.SelectedRows[0].Cells[2].Value.ToString()));
..worked. Thanks!
|
|
|
|
|
ive been using xptable, however, i have no clue as to how to add items to the combobox cell. has anyone figured this out?
|
|
|
|
|
What is xptable?
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
|
|
Dude, why don't you download the demo application. It will show you how to do exactly that.
|
|
|
|
|
Yeah, i was going through it, and i must have missed it, but i figured it out now...
|
|
|
|
|
how to know which procces['s] have access to a file in c#?
thnx
|
|
|
|
|
Check out for 'Task Manager Extension' article in CodeProject. That would give some idea.
You may need to use it through P/Invoke.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Task Manager Extension writen in vcc .... i dont understant vcc code ..can u give me c# or vb.net code?
|
|
|
|
|
Lots of things cannot be solved with .NET alone, so you better start learning to use Win32 calls as well.
Nobody here will translate the project for you just because you don't understand C++. We're all here to learn something and it seems to me that you've got an excellent opportunity to learn something new here...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hello all,
I am currently writing a very simple 2D game for school. I have created a Sprite class to display images on a windows form. In the constructor of the Form1 class, I have the following code:
handle = this.CreateGraphics();
handle is a Graphics object.
Then, in the Sprite class, this object is used to draw images to the screen:
public void Draw()
{
Matrix m = new Matrix();
m.Rotate(rotation);
handle.Transform = m;
handle.DrawImage(bitmap, destination);
handle.Dispose();
}
However, when I run the code, I get the following error on "handle.Transform = m;":
A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll
Commenting out the line for testing just moves the error to "handle.DrawImage(bitmap, destination);".
I've been stuck on this for hours now without any progress. Anyone that can give me a push in the right direction?
Many thanks!
|
|
|
|