Un saludo a todos gente :
Necesito saber como obtener los nombres de las columnas de una tabla determinada, por mas que busque no encuentro o no he sabido entender lo que he encontrado,esto es lo que tengo hasta ahora
CLASE PRINCIPAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bolas_V2
{
internal class Program
{
static void Main(string[] args)
{
Conexion con = new Conexion("pruebaDB.db");
Console.WriteLine(con.Dime_Conexion.FileName.ToString());
Operaciones oper = new Operaciones(con.Dime_Conexion);
oper.Consulta();
con.cierraConexion();
}
}
}
CLASE CONEXION
using Microsoft.Data.Sqlite;
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Bolas_V2
{
internal class Conexion
{
private SQLiteConnection con;
public SQLiteConnection Dime_Conexion => this.con;
public Conexion(string bbDd)
{
try
{
this.con = new SQLiteConnection("Data Source="+bbDd);
this.con.Open();
}
catch (SQLiteException ex)
{
Console.WriteLine(ex.Message);
}
}
public void cierraConexion()
{
this.con.Dispose();
}
}
}
CLASE OPERACIONES (la que estoy trabajando)
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bolas_V2
{
internal class Operaciones
{
private List<Object> lst = new List<Object>();
private SQLiteConnection con;
private SQLiteCommand commando;
private SQLiteDataReader lector;
public Operaciones(SQLiteConnection con)
{
this.con = con;
}
public void Consulta()
{
commando = this.con.CreateCommand();
commando.CommandText = "SELECT * FROM bolas";
lector = commando.ExecuteReader();
if (lector.HasRows)
{
while (lector.Read())
{
Console.WriteLine(lector.GetInt32(0) + " " + lector.GetInt32(1) + " " + lector.GetInt32(2));
}
}
}
}
}
Ahora lo que quiero conseguir es crear un método que me devuelva el nombre de las columnas de la tabla, no busco que me den la solución hecha, solo quiero orientacion de como debería hacerlo, y la consulta query para obtener dichos nombre.
Muchas gracias de antemano.