OLE DB acquired architecture information

xiaoxiao2021-03-06  27

Regarding how to obtain database architecture information, the database structure that acquires SQL Server and ORACAL may be relatively simple, and the method is also more. A method for all databases that can be linked to the ADO.NET link (such as the DBF free table, such as Access, DB4 format, etc.), first of all, linking a link string of various databases, all using ADO.NET, The namespace is: use system.data.oledb; use several databases to give an example, other database links are required to check here: http://www.connectionstrings.com/ But if OLE DB, OLEDBCONNECTION (.NET) Link mode.

SQL Server Database Connection String String Sconnstr = "Provider = Sqloledb; Data Source = Aron1; Initial Catalog = Pubs; User ID = SA; Password = AsDasd;"; Access Database Connection String String Sconnstr = "proviker = Microsoft.jet. OLEDB.4.0; Data Source = // SomePath // mydb.mdb; user ID = admin; password =; "; DBF table (DB4 format) connection string string sconnstr =" provike = microsoft.jet.Oledb.4.0; data Source = C: // folder; extended Properties = DBASE IV; user ID = admin; password = "; FoxPro database connection string string sconnstr =" provider = vfpoledb.1; data source = c: // mydataDirectory //; collating SEQUENCE = General "; Excel file connection string string sconnstr =" provider = microsoft.jet.OLDB.4.0; data source = c: //myexcel.xls; extended proties = "" Excel 8.0; HDR = yes; IMEX = 1 "" ";" UDL file connection string string sconnstr = "file name = c: //mydataLink.ud;", obtain the database architecture information, here I take the list of tables to get the database as an example, the code is as follows /// < Summary> /// acquire a list of tables for a database, you can use /// /// Database connection string // / Table Columns Public String [] getTablist (String Sconnstr) {if (Sconnstr == NULL ) Throw new ArgumentNullException ( "sConnStr"); string [] sTBList; using (OleDbConnection conn = new OleDbConnection (sConnStr)) {conn.Open (); DataTable dt = conn.GetOleDbSchemaTable (OleDbSchemaGuid.Tables, new object [] {null , NULL, NULL, "Table"}); conn.close (); if (dt.rows.count> 0) {stblist = new string [dt.rows.count]; int i = 0; Foreach (DataRow Dr in Dt.Rows) {stblist [i] =

转载请注明原文地址:https://www.9cbs.com/read-40350.html

New Post(0)