MIConnection connection = new MIConnection();
connection.Open();
MICommand miCommand = connection.CreateCommand();
miCommand.CommandText = "Select Country,Capital,Continent from world";
miCommand.Prepare();
MapInfo.Data.MIDataReader miReader = miCommand.ExecuteReader();
DataTable dt = new DataTable("Data");
for (int i = 0; i < miReader.FieldCount; i++)
{ DataColumn dc = dt.Columns.Add(miReader.GetName(i)); }
while (miReader.Read())
{
DataRow dr = dt.NewRow();
for (int i = 0; i < miReader.FieldCount; i++)
{ dr[i] = miReader.GetValue(i); }
dt.Rows.Add(dr);
}
dt.Columns[0].ColumnMapping = MappingType.Hidden;
dt.Columns[1].ColumnMapping = MappingType.Hidden;
dt.Columns[2].ColumnMapping = MappingType.Hidden;
GridView1.DataSource = dt;
GridView1.DataBind();
miReader.Close();
connection.Open();
MICommand miCommand = connection.CreateCommand();
miCommand.CommandText = "Select Country,Capital,Continent from world";
miCommand.Prepare();
MapInfo.Data.MIDataReader miReader = miCommand.ExecuteReader();
DataTable dt = new DataTable("Data");
for (int i = 0; i < miReader.FieldCount; i++)
{ DataColumn dc = dt.Columns.Add(miReader.GetName(i)); }
while (miReader.Read())
{
DataRow dr = dt.NewRow();
for (int i = 0; i < miReader.FieldCount; i++)
{ dr[i] = miReader.GetValue(i); }
dt.Rows.Add(dr);
}
dt.Columns[0].ColumnMapping = MappingType.Hidden;
dt.Columns[1].ColumnMapping = MappingType.Hidden;
dt.Columns[2].ColumnMapping = MappingType.Hidden;
GridView1.DataSource = dt;
GridView1.DataBind();
miReader.Close();