你可以参看下微软提供的API。
System.Data.SqlClient.SqlConnection
文件下都是定义,没有具体的实现,而我们能直接new SqlConnection
然后就直接使用它的方法。
C# code // 摘要:
// Represents an open connection to a SQL Server database. This class cannot
// be inherited.
[DefaultEvent("InfoMessage")]
public sealed class SqlConnection : DbConnection, ICloneable
{
// 摘要:
// Initializes a new instance of the System.Data.SqlClient.SqlConnection class.
public SqlConnection();
//
// 摘要:
// Initializes a new instance of the System.Data.SqlClient.SqlConnection class
// when given a string that contains the connection string.
//
// 参数:
// connectionString:
// The connection used to open the SQL Server database.
public SqlConnection(string connectionString);
// 摘要:
// Gets or sets the string used to open a SQL Server database.
//
// 返回结果:
// The connection string that includes the source database name, and other parameters
// needed to establish the initial connection. The default value is an empty
// string.
//
// 异常:
// System.ArgumentException:
// An invalid connection string argument has been supplied, or a required connection
// string argument has not been supplied.
[DefaultValue("")]
[ResDescription("SqlConnection_ConnectionString")]
[RecommendedAsConfigurable(true)]
[RefreshProperties(RefreshProperties.All)]
[ResCategory("DataCategory_Data")]
[Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public override string ConnectionString { get; set; }
//
// 摘要:
// Gets the time to wait while trying to establish a connection before terminating
// the attempt and generating an error.
//
// 返回结果:
// The time (in seconds) to wait for a connection to open. The default value
// is 15 seconds.
//
// 异常:
// System.ArgumentException:
// The value set is less than 0.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription("SqlConnection_ConnectionTimeout")]
public override int ConnectionTimeout { get; }
//
// 摘要:
// Gets the name of the current database or the database to be used after a
// connection is opened.
//
// 返回结果:
// The name of the current database or the name of the database to be used after
// a connection is opened. The default value is an empty string.
[ResDescription("SqlConnection_Database")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string Database { get; }
//
// 摘要:
// Gets the name of the instance of SQL Server to which to connect.
//
// 返回结果:
// The name of the instance of SQL Server to which to connect. The default value
// is an empty string.
[Browsable(true)]
[ResDescription("SqlConnection_DataSource")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string DataSource { get; } |