private void QueryDBSchema()
{
// Schema information for the current database connection.
DataTable schema;
// Loop counter.
int loop = 0;
// Clean up the menu so the menu item does not hang while this function executes.
this.Refresh();
// Instantiate an OleDbConnection object.
using (OleDbConnection oleDbConnection = new OleDbConnection("Provider=SQLOLEDB;Password=sa123;User ID=sa;Data Source=mukesh;Initial Catalog=Medi;"))
{
try
{
// Open the connection.
oleDbConnection.Open();
// Retrieve the Table objects.
schema = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object[] { null, null, null, "table" });
// Store the table names in the object collection.
for (loop = 0; loop < schema.Rows.Count; loop++)
{
objects.Add(schema.Rows[loop].ItemArray[2].ToString());
}
}
catch (Exception e)
{
// Messages.BadConnection(e);
}
}
}
This function for getting table name in objects list.
// Instantiate the objects collection.
this.objects = new Collection<string>();
QueryDBSchema();
// Gather each of the selected items (if any) into a collection object.
foreach (string item in this.objects)
{
//This should be like this
// "item" obj = new "item";
}
in foreach loop i want to create class object with string saved in item value.How this possible in c# also same name class is exits in different namespace and i want to assign the object to another same class in different namespace and call function named like save in obj1.
such as
// "item" obj1 = new "item"; // "Item" obj2 = new "item";
obj1=obj2; obj1.Save();