lamp

Browse by Tags

Sorry, but there are no more tags available to filter with.
A generic way to call ExecuteScalar
05 February 10 07:16 AM | Frederick.Chapleau | with no comments
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)    ...
Filed under:
Usage of static constant for SQL Statements
01 February 10 01:01 PM | Frederick.Chapleau | with no comments
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.
Filed under:
A dataset can be more than a dataset
10 July 09 08:19 AM | Frederick.Chapleau | with no comments
A dataset is a set of data, but when you want to query multiple one, you might want to return a ResultSet that is a combination of multiple table inside your dataset. They can have references or simple no link between them... be return is a single call...
Filed under:
Use only one connection
26 June 09 11:10 PM | Frederick.Chapleau | with no comments
A connection can be open, and closed at each time, but a better way to use them is to open one, and query everything in the using. Do not forget that you can only do that when you are NOT using Datareader! An exclusive connection is required in that case...
Filed under:
TCP/IP SQL Connection
24 June 09 12:53 PM | Frederick.Chapleau | with no comments
TCP/IP and Named Pipe can be used as SQL Connections, but when to use one or the other. TCP/IP seams to be more efficient on slower network, and on fast one, both are comparable. -f. ref: http://msdn.microsoft.com/en-us/library/aa178138(SQL.80).aspx
Filed under:
AddWithValue, is it really good?
21 June 09 11:10 PM | Frederick.Chapleau | with no comments
Yes... This is a good question. When you use AddWithValue, you just relying on the implicit SQL conversion between a nvarchar(4000) and the real datatype... So, I’m returning the question to you: is it good, in your case? -f.
Filed under: