Hi,
I was wondering if anyone has some perspective as to what the best way
to query an MS SQL Server database is using C#?
Currently, I am using the SqlConnection, SqlCommand and SqlDataReader
classes by opening a connection, writing an query string and passing it
to the SqlCommand object along with the SqlConnection object.
eg.
SqlConnection connection = new SqlConnection(/connectionString/);
connection.Open();
string query = "SELECT ...";
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader = command.ExecuteReader();
[...]
(or something like that - I cut out most of the code)
Now this is okay, but I am finding it quite complicated to dynamically
generate queries using this technique, especially if some of the values
are /null/.
Is there an easier/better way of creating the query string, or am I
stuck with using IF statements and "query += ..." to build them?
Cheers,
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
NP: Genesis - Dance on a Volcano (Live)