C# Mastery Hub
Home
Challenges
Discussion
Lessons
Core Topics
C# Fundamentals
Console Applications
Classes & OOP
Windows Forms
ASP.NET Core
SQL Server
VS & SQL Connection
RDLC Reports
.NET MAUI
Getting Started
Getting Started
Website Development
SEO Guide
Security
Project Workflow
Extra Topics
Cloud & Deployment
AWS Cloud
Deployment
About
Contact
Test Your Knowledge
VS & SQL Connection Quiz
Answer all questions to test your understanding
1
What is a connection string used for?
To tell your app how to find the database
To store user passwords
To configure logging
To set the application name
2
What authentication method uses your Windows credentials?
SQL Authentication
Windows Authentication
Azure Authentication
Basic Authentication
3
Where should you store connection strings in an ASP.NET Core app?
Hard-coded in the C# file
In appsettings.json
In the database
In a text file
4
What is the correct syntax for a SQL Server connection string?
Server=localhost;Database=SchoolDB;Trusted_Connection=True;
Server=localhost;Database=SchoolDB;UseWindowsAuth=True;
Host=localhost;Database=SchoolDB;Auth=Windows;
Data Source=localhost;DB=SchoolDB;WindowsAuth=true;
5
How do you read a connection string from appsettings.json in C#?
Configuration.GetConnectionString('SchoolDb')
Configuration.GetString('SchoolDb')
Configuration.GetValue('SchoolDb')
Configuration.Read('SchoolDb')
6
Which NuGet package is needed for SQL Server connections in modern .NET?
System.Data.SqlClient
Microsoft.Data.SqlClient
Microsoft.SqlServer
System.SqlServer
7
What is the purpose of SqlCommand in ADO.NET?
To connect to the database
To execute SQL commands
To read data from the database
To store data
8
What does 'using' do with SqlConnection?
Makes the connection faster
Automatically closes and disposes the connection
Creates multiple connections
Encrypts the connection
9
What method reads data from a SqlCommand?
ExecuteReader()
ReadData()
GetData()
FetchData()
10
What is SqlParameter used for?
To store configuration values
To safely pass values to SQL commands
To create database tables
To read data from tables
11
Which method executes a command that doesn't return any rows?
ExecuteScalar()
ExecuteNonQuery()
ExecuteReader()
ExecuteTable()
12
What is the biggest risk of using string concatenation in SQL queries?
It makes the code slower
SQL Injection attacks
It uses more memory
It's hard to read
13
What is the correct way to pass values to a SQL command?
String concatenation
Using SqlParameter with @@ParameterName
Directly in the query string
Using string interpolation
14
What does ExecuteNonQuery() return?
The number of rows affected
A DataReader
A DataTable
A scalar value
15
Which of these is a safe SQL command?
DELETE FROM Students WHERE StudentId = 5
DELETE FROM Students WHERE StudentId = ' + studentId
DELETE FROM Students WHERE StudentId = @@StudentId
DELETE FROM Students WHERE StudentId = {studentId}
16
What is the main characteristic of SqlDataReader?
Loads all data into memory at once
Reads data forward-only, one row at a time
Allows editing data offline
Stores data in a DataSet
17
What is the main characteristic of SqlDataAdapter?
Reads data one row at a time
Loads data into a DataTable for offline access
Only executes stored procedures
Connects to multiple databases
18
Which one is better for binding to a Windows Forms DataGridView?
SqlDataReader
SqlDataAdapter
They are both the same
Neither works
19
Which one is more memory efficient for reading large datasets?
SqlDataAdapter
SqlDataReader
They use the same memory
Neither is memory efficient
20
What method fills a DataTable using SqlDataAdapter?
Load()
Fill()
Read()
Execute()
21
What does EF Core stand for?
Entity Framework Core
Entity Form Core
Environment Framework Core
Extended Framework Core
22
What is an ORM?
Object-Relational Mapper
Object-Resource Manager
Order-Resource Model
Object-Reference Model
23
What does DbSet represent in EF Core?
A single row in the database
A collection of entities that maps to a table
A database connection
A SQL command
24
What method saves changes to the database in EF Core?
Save()
SaveChanges()
SaveChangesAsync()
Both B and C
25
What is the advantage of EF Core over ADO.NET?
It's always faster than ADO.NET
You write less SQL and it's safer by default
It uses less memory
It connects to more databases
26
How do you read data in EF Core?
Using SQL strings
Using LINQ queries
Using stored procedures only
Using DataReader
27
Which method adds a new entity to the database in EF Core?
context.Add()
context.Insert()
context.Create()
context.New()
Submit Quiz