hi every body.i need a component for working with every kind of databases in app. i want to access and atach to any kind of databases and bring tabals and it's fileds to my app. please help me.thanks alot.
This is a very general question. For example you probably will be out of luck to find a single component that covers object-oriented database systems and relational database systems equally well.
Maybe you can give more specific details?
If you can restrict the requirement to relational database systems a good starting point may be NHibernate or even fluent-nhibernate.
This depends on your .NET version. But if you are using .NET 3.5 then take a look at Linq-To-Sql or/and the Entity-Framework. Those are all build in directly to the framework and are nicely integrated into the userinterface-part of .NET.
The simple answer is: No, there is no .Net component that let's you work with every kind of database.
Even different relational database systems use different SQL-dialects, not to mention object-oriented database systems, hierarchical database and other kinds...
The closest technology in my view would be the ODBC objects in the ADO.net, but as the other mentionned, it will not sort out the SQL dialects issues (Oracle, Access, etc has a slightly different syntax than SQL Server, for example).
An ORM (object relational mapping) can probably help with that, as long as it works with the ODBC objects from ADO.net.
U can do it,but not predefined component .Jus have to create of ur own .I had the same requirement in my project .Plz look to the below code .It might help.
if (database != "EXCEL") // just some dummy string to pass if its excel file .or else the database name in case of other DBs
{
connectionString = "Data Source=" + source + ";Provider=SQLOLEDB;Initial Catalog=" + database + ";User Id=" + username + ";password=" + password;
}
else
{
connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + source + ";Extended Properties=\"Excel 12.0;HDR=YES;\"";
}
//string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ElementDependencies.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
OleDbConnection con = new OleDbConnection(connectionString);
DataTable schemaCols, schemaTbl;
List<string> tablesnames = new List<string>();
try
{
con.Open();
object[] objArrRestrict;
objArrRestrict = new object[] { null, null, null, "TABLE" };
schemaTbl = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, objArrRestrict);
foreach (DataRow row in schemaTbl.Rows)
{
tablesnames.Add(row["TABLE_NAME"].ToString());
}
List<string> columnnames = new List<string>();
foreach (string str in tablesnames)
{
string selTbl = str;
object[] objArrRestrictNew = new object[] { null, null, selTbl, null };
schemaCols = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, objArrRestrictNew);
foreach (DataRow row in schemaCols.Rows)
{
columnnames.Add(row["COLUMN_NAME"].ToString());
}
}
}