using - , try/finally Dispose finally, try/catch, , - , ? ?
, , , ...
using, :
using (SqlConnection connSQL = new SqlConnection(strConn)) {
, , . , SqlDataReader using. , , , - IDisposable, .
, sqlParameters . foreach , , for (int i = 0; i < sqlParameters.Length; i++), , "" .
, :
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(strPreparedStatement, connection))
{
if (sqlParameters != null)
{
foreach (SqlParameter parameter in sqlParameters)
{
command.Parameters.Add(parameter);
}
}
using (SqlDataReader reader = command.ExecuteReader())
{
DataTable table = new DataTable();
table.Load(reader);
return table;
}
}
}