How to write in the array the column names of the database table (access)?
Connection Code:
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;"+ @"Data Source= C:\Users\Person.accdb"); How to write in the array the column names of the database table (access)?
Connection Code:
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;"+ @"Data Source= C:\Users\Person.accdb"); using System.Data; using System.Data.OleDb; using System.Linq; namespace ConsoleApplication52 { class Program { static void Main(string[] args) { using (OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data Source= C:\Users\Person.accdb")) { con.Open(); string [] columns = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, null) .AsEnumerable() .Where(r => r.Field<string>("TABLE_NAME") == "Students") .Select(r => r.Field<string>("COLUMN_NAME")) .ToArray(); } } } } Source: https://ru.stackoverflow.com/questions/508797/
All Articles