⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ref_connectionprovider.htm

📁 LLBLGen 1.21 Sourcecode
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
<TITLE>LLBLGen::ConnectionProvider class</TITLE>
<link rel="STYLESHEET" type="text/css" href="general.css">
</HEAD>
<BODY>
<br>
<h2>LLBLGen::ConnectionProvider class</h2>
<p>
	LLBLGen generates, when the 'Include Connection Provider Class support' option is checked on the
	<a href="gui_netcode.htm">.NET Code tab</a>, a class called [Class prefix]ConnectionProvider. This class
	is used to share an open SqlConnection among different data-access tier classes which is done by passing 
	an instance of this class to the property MainConnectionProvider. The data-access tier class which receives
	an instance of the [Class prefix]ConnectionProvider will then use the SqlConnection object of the 
	[Class prefix]ConnectionProvider object, plus, when available, the SqlTransaction object of a started transaction.
	When a data-access tier class doesn't receive a [Class prefix]ConnectionProvider object, it will create
	a new SqlConnection object each time a method is called, and thus the methods of these classes will not 
	be able to participate in an ADO.NET transaction. Due to the usage of ADO.NET's transaction functionality,
	it is not possible to nest transactions like it was possible with ADO. You can however use savepoints to
	have multiple roll back possibilities during a transaction.
</p>
<p>
	Below are the different properties and methods of the [Class prefix]ConnectionProvider class, their meaning
	and when to use them. The setting on the <a href="gui_netcode.htm">.NET Code tab</a> about how to supply 
	the connection string is also implemented in the [Class prefix]ConnectionProvider class. See for an example
	how to use this class the example: <a href="usingdataaccess.htm">A Very simple database</a>, which illustrates
	the transaction functionality using this class.
</p>
<h4>Properties</h4>
<p>
	<b class="SmallHdr">[prefix]CurrentTransaction</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table2">
	<tr>
		<td valign="top" width="140"><b>When generated</b></td>
		<td>Always.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Type</b></td>
		<td>SqlTransaction</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Holds the SqlTransaction object of the current started transaction. Users should first check
			[prefix]IsTransactionPending if there is a transaction pending.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Read / Write</b></td>
		<td>Read only.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Hungarian Prefix</b></td>
		<td>st</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">[prefix]ConnectionString</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table3">
	<tr>
		<td valign="top" width="140"><b>When generated</b></td>
		<td>When 'Using a property' is checked under 'Connection String retrieval settings' 
			on the <a href="gui_netcode.htm">.NET code tab</a>.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Type</b></td>
		<td>string (C#) or String (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Used to pass the connection string value to the [Class prefix]ConnectionProvider class so a method call which uses
			a new SqlConnection object, will be using this string as the connection string. It's not necessary
			to pass this string before each call, but it is necessary to pass a value to this property
			after each time a new instance of the [Class prefix]ConnectionProvider class is created.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Read / Write</b></td>
		<td>Write only</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Hungarian Prefix</b></td>
		<td>s</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Accepts Null / DBNull</b></td>
		<td>Accepts null (C#) / Nothing (VB.NET), allthough this will render the instance of the class useless since
			no connection string is known so no database connection can be made.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">[prefix]IsTransactionPending</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table4">
	<tr>
		<td valign="top" width="140"><b>When generated</b></td>
		<td>Always.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>To flag if [prefix]CurrentTransaction is valid. Is true when there is a valid SqlTransaction object available, false otherwise</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Read / Write</b></td>
		<td>Read only</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Hungarian Prefix</b></td>
		<td>b</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">[prefix]DBConnection</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table12">
	<tr>
		<td valign="top" width="140"><b>When generated</b></td>
		<td>Allways.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Type</b></td>
		<td>SqlConnection.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>The actual SqlConnection object which should be used as active connection.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Read / Write</b></td>
		<td>Read only.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Hungarian Prefix</b></td>
		<td>sco</td>
	</tr>
	</table>
</p>
<h4>Methods</h4>
<p>
	<b class="SmallHdr">Dispose</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table5">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>void</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td>Not applicable.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Implementation of System.IDisposable.Dispose.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td>None.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">OpenConnection</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table1">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td><b>True</b> if the method succeeded, <b>false</b> otherwise. When an error occures, the method will throw an exception, which
			is the exception caught encapsulated in a new Exception exception.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Opens the SqlConnection object of the class, which is shared by the data-access tier classes where this instance
			of the [Class prefix]ConnectionProvider class is passed to. Call this method before any other method of this
			class.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td>None.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">BeginTransaction</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table6">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td><b>True</b> if the method succeeded, <b>false</b> otherwise. When an error occures, the method will throw an exception, which
			is the exception caught encapsulated in a new Exception exception.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Starts an ADO.NET transaction over the open SqlConnection connection, which is opened by <b>OpenConnection</b>.
			The started connection is then used by all data-access tier objects among which this instance of the 
			[Class prefix]ConnectionProvider class is shared and can be commited by calling the method <b>CommitTransaction</b>
			or rolled back by <b>RollbackTransaction(<i>TransactionName</i>)</b></td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td><b>TransactionName</b>. Type: string (C#) or String (VB.NET). <br>
			The name of the transaction which is started. Use this name to refer to this transaction when calling
			<b>RollbackTransaction</b>.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">CommitTransaction</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table7">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td><b>True</b> if the method succeeded, <b>false</b> otherwise. When an error occures, the method will throw an exception, which
			is the exception caught encapsulated in a new Exception exception.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Commits a pending transaction, started with <b>BeginTransaction</b>. All actions performed in this transaction,
			which means: all actions done by methodcalls of data-access tier classes among which this instance of the
			[Class prefix]ConnectionProvider class is shared, are 'committed' in the database, and are finalized, which
			means the actions can't be rolled back. 
			</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td>None.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">RollbackTransaction</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table8">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td><b>True</b> if the method succeeded, <b>false</b> otherwise. When an error occures, the method will throw an exception, which
			is the exception caught encapsulated in a new Exception exception.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Rolls back the transaction started with <b>BeginTransaction</b> and has the same value for TransactionName, or
			rolls back the transaction to the savepoint with the name <i>TransactionName</i>, which is saved by the
			method <b>SaveTransaction</b>.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td><b>TransactionName</b>. Type: string (C#) or String (VB.NET). <br>
			The name of the transaction or safepoint which should be rolled back.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">SaveTransaction</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table9">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td><b>True</b> if the method succeeded, <b>false</b> otherwise. When an error occures, the method will throw an exception, which
			is the exception caught encapsulated in a new Exception exception.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Saves the current transaction to a so called <i>savepoint</i>. The transaction is then </td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td><b>TransactionName</b>. Type: string (C#) or String (VB.NET). <br>
			The name of the savepoint. A transaction can be rolled back to this savepoint, or can be rolled back totally. When
			you want to roll back to this savepoint, specify the TransactionName passed to BeginTransaction to roll back
			the complete transaction.</td>
	</tr>
	</table>
	<br clear="all"><br>
	<b class="SmallHdr">CloseConnection</b>
	<table width="100%" cellpadding="2" cellspacing="0" border="1" ID="Table10">
	<tr>
		<td valign="top" width="140"><b>Return Type</b></td>
		<td>bool (C#) or Boolean (VB.NET)</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Return Type desc.</b></td>
		<td><b>True</b> if the method succeeded, <b>false</b> otherwise. When an error occures, the method will throw an exception, which
			is the exception caught encapsulated in a new Exception exception.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Purpose</b></td>
		<td>Closes the SqlConnection opened with <b>OpenConnection</b>. When <b>CommitPendingTransaction</b> is true, the pending
			transaction is committed, otherwise the pending transaction is aborted (rolled back). When no pending transaction
			is available, no transaction is committed nor rolled back.</td>
	</tr>
	<tr>
		<td valign="top" width="140"><b>Parameters</b></td>
		<td><b>CommitPendingTransaction</b>. Type: bool (C#) or Boolean (VB.NET)<br>
			The flag to this method what to do when there is a pending transaction present when this method is called. 
			When <b>True</b>, a pending transaction is committed, when <b>False</b>, a pending transaction is rolled back
			completely. When no pending transaction is present, this parameter is ignored.</td>
	</tr>
	</table>
</p>
<div align="right" class="SmallFontTOC">
	<hr size="1" width="60%" align="right">
	LLBLGen v1.2 documentation. &copy; 2002 <a href="http://www.sd.nl/" target="_blank">Solutions Design</a>
</div>
<br><br><br>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -