I have a SQL Server Compact Edition Database file, and I want to display all the tables on it as nodes into a TreeView control in my windows application.
Unfortunately, I don’t know how to.
This is what I have now:
private void PopulateTreeView()
{
SqlCeCommand cmd = new SqlCeCommand();
try
{
using (SqlCeConnection conn = new SqlCeConnection("Data Source=" + connString))
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
conn.Open();
cmd.Connection = conn;
cmd.ExecuteNonQuery();
// Don't know what's next...
}
}
catch (Exception x)
{
MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
cmd.Dispose();
}
}
something like
you can get fancier with the node creation. Have a look at the various constructors to see what you want.