Wednesday, February 26, 2025
18- Graphic creation
a 1 mark per bullet [13]:
• Rectangle created.
• Triangle created and positioned central to rectangle.
• Outline of both objects is dark blue
• … … less than 4 pt thick.
• Gradient fill used for television.
• Text says Titania
• … inside the television • ..in green
• … sans-serif font • … in an arc.
• Font is a suitable size for the television.
• Image saved as vector
• … no more than 250 by 250 pixels
b. 1 mark per bullet [4]:
• Vector is made of points and calculations
• … when it is resized the proportions are kept
• … it does not pixelate
• … unlike a bitmap.
c 1 mark per bullet [6]:
• Lossy compression removes some data.
• … the decompressed image is not the same as the original.
* Reduce the number of colours
• … fewer colours means less data to store per pixel.
• Reduce the resolution
• … means fewer pixels to store therefore less data.
a 1 mark per bullet [15]:
• Rectangle created
• … warped/distorted on the top edge only
• … appropriate level of distortion to match image.
• Six circles added
• … in black
• … all identical
• … and evenly spaced.
• Black rectangle drawn
• … outline only.
• Word rollercoaster added
• … in green
• … in sans-serif font
• … set to an arc
• … inside the rollercoaster rectangle
• … an appropriate size.
b For example [3]:
• .jpg
• Compresses the image to reduce the file size.
• There is no transparency.
c 1 mark per bullet [4]:
• RGB colours are made up of red green and blue
• … values between 0 and 255/FF for each colour.
• CMYK are made of cyan, magenta, yellow and black
• … values are a percentage between 0 and 100.
Tuesday, February 25, 2025
Test the connection string in your ASP.NET Core MVC
To test the connection string in your ASP.NET Core MVC application, follow these steps:
1. Inject and Read Connection String in a Controller
You can inject IConfiguration
into a controller and check if the connection string is being read correctly.
Modify HomeController.cs
(or create a new controller)
csharpusing Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Data.SqlClient;
namespace YourNamespace.Controllers
{
public class HomeController : Controller
{
private readonly IConfiguration _configuration;
public HomeController(IConfiguration configuration)
{
_configuration = configuration;
}
public IActionResult TestConnection()
{
string connectionString = _configuration.GetConnectionString("ConnStrMVC");
try
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
return Content("Database Connection Successful!");
}
}
catch (Exception ex)
{
return Content("Database Connection Failed: " + ex.Message);
}
}
}
}
2. Configure Dependency Injection in Program.cs
Ensure that appsettings.json
is properly loaded by adding builder.Configuration
in Program.cs
:
csharpvar builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
// Make sure appsettings.json is properly loaded
builder.Services.Configure<YourAppSettings>(builder.Configuration.GetSection("ConnectionStrings"));
var app = builder.Build();
3. Run and Test
- Start your application.
- Navigate to:arduino
https://localhost:port/Home/TestConnection
- If the connection is successful, it will show "Database Connection Successful!"
- If there is an issue, the error message will be displayed.
4. (Optional) Test in Program.cs
Before Running the App
If you want to test before the application starts, add the following in Program.cs
:
csharpstring connectionString = builder.Configuration.GetConnectionString("ConnStrMVC");
try
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
Console.WriteLine("Database Connection Successful!");
}
}
catch (Exception ex)
{
Console.WriteLine("Database Connection Failed: " + ex.Message);
}
Then, run the project and check the Output Console for results.
5. Verify SQL Server
If the connection fails, check:
- SQL Server is running (
services.msc
→ SQL Server is started) - Correct server name (
.
or(local)
for local SQL, or specifyMACHINE_NAME\SQLEXPRESS
if using SQL Express) - TrustServerCertificate=True if using Windows Authentication
- Use
User ID=sa;Password=yourpassword;
if using SQL Authentication
This method ensures that your connection string works before implementing database operations.