本文整理汇总了C#中System.Data.OleDb.OleDbConnection.Database属性的典型用法代码示例。如果您正苦于以下问题:C# OleDbConnection.Database属性的具体用法?C# OleDbConnection.Database怎么用?C# OleDbConnection.Database使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Data.OleDb.OleDbConnection
的用法示例。
在下文中一共展示了OleDbConnection.Database属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenConnection
static void OpenConnection(string connectionString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
try
{
connection.Open();
Console.WriteLine("ServerVersion: {0} \nDatabase: {1}",
connection.ServerVersion, connection.Database);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
}
示例2: Main
//引入命名空间
using System;
using System.Data;
using System.Data.OleDb;
class AccessConnect {
static void Main()
{
string connString = @"provider = microsoft.jet.oledb.4.0;data source = Employee.mdb;";
OleDbConnection conn = new OleDbConnection(connString);
try
{
conn.Open();
Console.WriteLine("Connection opened.");
Console.WriteLine("Connection Properties:");
Console.WriteLine("\tConnection String: {0}", conn.ConnectionString);
Console.WriteLine("\tDatabase: {0}",conn.Database);
Console.WriteLine("\tDataSource: {0}",conn.DataSource);
Console.WriteLine("\tServerVersion: {0}", conn.ServerVersion);
Console.WriteLine("\tState: {0}", conn.State);
} catch (OleDbException e) {
Console.WriteLine("Error: " + e);
} finally {
conn.Close();
Console.WriteLine("Connection closed.");
}
}
}