Premiere commit - Omika
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
// Probe LECTURE SEULE ciblé : déterminer si le fichier "Lieu" existe dans BATIK_TEST.
|
||||
// Aucune écriture. Source de vérité : la base réelle via OLE DB PCSOFT.HFSQL.
|
||||
using System.Data.OleDb;
|
||||
|
||||
const string server = "127.0.0.1";
|
||||
const int port = 4900;
|
||||
const string user = "susana";
|
||||
const string password = "123";
|
||||
const string database = "BATIK_TEST";
|
||||
|
||||
string BuildConnStr() =>
|
||||
$"Provider=PCSOFT.HFSQL;Data Source={server}:{port};Initial Catalog={database};User ID={user};Password={password}";
|
||||
|
||||
Console.WriteLine($"=== Probe Lieu (base {database}) ===");
|
||||
|
||||
try
|
||||
{
|
||||
using var conn = new OleDbConnection(BuildConnStr());
|
||||
conn.Open();
|
||||
Console.WriteLine("Connexion OK.");
|
||||
|
||||
// 1) Lister les tables disponibles (schéma) pour voir si "Lieu" existe.
|
||||
Console.WriteLine("\n--- Tables disponibles (GetOleDbSchemaTable) ---");
|
||||
try
|
||||
{
|
||||
var tables = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||||
if (tables is null)
|
||||
{
|
||||
Console.WriteLine(" (aucune table retournée)");
|
||||
}
|
||||
else
|
||||
{
|
||||
var names = new List<string>();
|
||||
foreach (System.Data.DataRow row in tables.Rows)
|
||||
{
|
||||
if (row.Table.Columns.Contains("TABLE_NAME"))
|
||||
{
|
||||
names.Add(row["TABLE_NAME"]?.ToString() ?? "");
|
||||
}
|
||||
}
|
||||
names.Sort(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var n in names)
|
||||
{
|
||||
Console.WriteLine($" {n}");
|
||||
}
|
||||
Console.WriteLine($" Total: {names.Count}");
|
||||
Console.WriteLine($" Lieu présent: {(names.Contains("Lieu", StringComparer.OrdinalIgnoreCase) ? "OUI" : "NON")}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($" ERREUR listing tables: {ex.Message}");
|
||||
}
|
||||
|
||||
// 2) Tester la requête réelle FROM Lieu (contrôle de l'erreur 70114).
|
||||
Console.WriteLine("\n--- SELECT LI_PKID FROM Lieu ---");
|
||||
try
|
||||
{
|
||||
using var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = "SELECT LI_PKID FROM Lieu";
|
||||
using var reader = cmd.ExecuteReader();
|
||||
int rowCount = 0;
|
||||
while (reader.Read())
|
||||
{
|
||||
rowCount++;
|
||||
}
|
||||
Console.WriteLine($" rows={rowCount}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($" ERREUR: {ex.Message}");
|
||||
}
|
||||
|
||||
// 3) Contrôle : Client doit fonctionner (le snapshot Clients passe).
|
||||
Console.WriteLine("\n--- SELECT CL_PKID FROM Client (contrôle) ---");
|
||||
try
|
||||
{
|
||||
using var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = "SELECT CL_PKID FROM Client";
|
||||
using var reader = cmd.ExecuteReader();
|
||||
int rowCount = 0;
|
||||
while (reader.Read())
|
||||
{
|
||||
rowCount++;
|
||||
}
|
||||
Console.WriteLine($" rows={rowCount}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($" ERREUR: {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"ERREUR connexion: {ex.Message}");
|
||||
}
|
||||
|
||||
Console.WriteLine("\nProbe Lieu terminé (lecture seule).");
|
||||
Reference in New Issue
Block a user