Update data access layer, begin acquiring raw data

This commit is contained in:
Aaron Po
2025-11-17 02:39:40 -05:00
parent b86607e37a
commit fc2e8c9b6d
15 changed files with 166221 additions and 7 deletions

View File

@@ -1,3 +1,55 @@
namespace DataAccessLayer;
using System;
using System.Data;
using Microsoft.Data.SqlClient;
public class Class1 { }
namespace DataAccessLayer
{
public class DatabaseHelper
{
private readonly string _connectionString;
public DatabaseHelper(string connectionString)
{
_connectionString = connectionString;
}
public void ExecuteRawSql(string query)
{
try
{
using (
SqlConnection connection = new SqlConnection(
_connectionString
)
)
{
connection.Open();
using (
SqlCommand command = new SqlCommand(query, connection)
)
{
command.CommandType = CommandType.Text;
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
Console.WriteLine(
$"{reader.GetName(i)}: {reader.GetValue(i)}"
);
}
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
}
}