Dynamicweb Namespace > Database Class > CreateDataReader Method : CreateDataReader(String,String) Method |
'Declaration
Public Overloads Shared Function CreateDataReader( _ ByVal sql As String, _ ByVal database As String _ ) As IDataReader
public static IDataReader CreateDataReader( string sql, string database )
namespace Dynamicweb.Examples.CSharp { class DatabaseCreateDataReader { public void DataReaderSample() { //Create a DataReader on the default database using (var myDr = Database.CreateDataReader("SELECT TOP 10 * FROM Page")) { while (myDr.Read()) { var pageId = Input.FormatInteger(myDr["PageID"]); } } //Create a DataReader on alternate database using (var myDr = Database.CreateDataReader("SELECT TOP 10 * FROM AccessUser", "Access.mdb")) { while (myDr.Read()) { var pageId = Input.FormatInteger(myDr["AccessUserID"]); } } } } }
Public Class DatabaseCreateDataReader Public Sub DataReaderSample() 'Create a DataReader on the default database Using myDr As IDataReader = Database.CreateDataReader("SELECT TOP 10 * FROM Page") Do While myDr.Read Dim pageId As Integer = Input.FormatInteger(myDr.Item("PageID")) Loop End Using 'Create a DataReader on alternate database Using myDr As IDataReader = Database.CreateDataReader("SELECT TOP 10 * FROM AccessUser", "Access.mdb") Do While myDr.Read Dim pageId As Integer = Input.FormatInteger(myDr.Item("AccessUserID")) Loop End Using End Sub End Class
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2