Dynamicweb Namespace > Database Class > CreateDataReader Method : CreateDataReader(String,String,Int32) Method |
'Declaration
Public Overloads Shared Function CreateDataReader( _ ByVal sql As String, _ ByVal database As String, _ ByVal commandTimeout As Integer _ ) As IDataReader
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