I would like to read the table and column information in C#.NET Windows application. I know that there is SMO base access for SQL Server. On similar ground is there any API
You can use the GetSchema
method :
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SQLite");
using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = @"Data Source=D:\tmp\test.db";
connection.Open();
DataTable tables = connection.GetSchema("Tables");
DataTable columns = connection.GetSchema("Columns");
tables.Dump();
columns.Dump();
}
GetSchema
returns a DataTable that contains information about the tables, columns, or whatever you specify. Valid GetSchema
arguments for SQLite include: