-
-
When calling execute Scalar, we always begin by calling it with some code like
int i = cmd.ExecuteScalar();
What’s wrong with this picture?… what if, the first field of the first row is… NULL?
so…
int i;
object o = cmd.ExecuteScalar();
if(o != null)
i = (int)o;
-f.
-
-
Ever wonder of a more efficient way to write multiple lines strings?
Check this out…
The first way...
string myString1 = "This is the first line of my string.\n" +
"This is the second line of my string.\n" +
"This is the third line of the string.\n";
And a more efficient way...
string myString2 = @"This is the first line of my string.
This is the second line of my string.
This is the third line of the string.";
-f.
-
-
Embedding SQL statement is sometimes useful. A good practice is to centralize them in a class, using public constants...
public const string SQL_MYTABLE_INSERT = "INSERT MYTABLE (FIELD) VALUES (@FIELDVALUE)";
-f.