Geeks With Blogs
marocanu2001 technicle blog March 2010 Entries
InvokeRequired not reliable?
InvalidOperationException: Cross-thread operation not valid: Control 'progressBar' accessed from a thread other than the thread it was created ... Now this is not a nice way to start a day! not even if it's a Monday! So you have seen this and already thought, come on, this is an old one, just ask whether InvokeRequired before calling the method in the control, something like this: if (progressBar.InvokeRequired) { progressBar.Invoke ( new MethodInvoker( delegate { progressBar.Value = 50; }) ) }else ......

Posted On Saturday, March 27, 2010 11:16 PM

System.Data.Sqlclient.Sqlexception: Line1 incorrect syntax ...

Given a SqlConnection, a SqlCommand if you need to execute a stored procedure it is enough to specify the stored procedure name as the CommandText and it will work.

Now the surprise is that if you also add parametres, you get this creepy error: SqlException: Line 1 incorrect syntax near [storedProcedureName].

The quick fix is to specify the CommandType to be StoredProcedure.

Posted On Thursday, March 25, 2010 3:36 AM

Copyright © marocanu2001 | Powered by: