public SqlDataReader GetSqlDataReader(SqlCommand sqlCommand) { HollywoodConnectionData.GetSqlConnection(); HollywoodConnectionData.OpenSqlConnection(); try { return(sqlCommand.ExecuteReader()); } catch (Exception) { HollywoodConnectionData.CloseSqlConnection(); sqlCommand.Dispose(); return(null); } }
public SqlCommand GetSqlCommand(int movieId) { string query = "SELECT Actors.LastName, Actors.FirstName, Actors.DateOfBirth FROM Actors INNER JOIN Roles ON Actors.ActorID = Roles.ActorID WHERE MovieID = @MovieID"; SqlCommand sqlCommand = null; try { SqlParameter sqlParameter = GetSqlParameters(movieId); sqlCommand = new SqlCommand(query, HollywoodConnectionData.GetSqlConnection()); sqlCommand.CommandType = CommandType.Text; sqlCommand.Parameters.Add(sqlParameter); return(sqlCommand); } catch (Exception) { HollywoodConnectionData.CloseSqlConnection(); sqlCommand.Dispose(); return(null); } }