Dynamicweb Namespace > Database Class > CreateDataTable Method : CreateDataTable(String,String) Method |
using System.Data; namespace Dynamicweb.Examples.CSharp { class DatabaseCreateDataTable { public void DataTableSample() { //Create DataTable on the default database var myDataTable = Database.CreateDataTable("SELECT TOP 10 * FROM Page"); //Loop rows in DataTable foreach (DataRow row in myDataTable.Rows) { var pageId = Input.FormatInteger(row["PageID"]); } //Create DataTable on alternate database DataTable myDataTable2 = Database.CreateDataTable("SELECT TOP 10 * FROM AccessUser", "Access.mdb"); //Loop rows in DataTable foreach (DataRow row in myDataTable.Rows) { var userId = Input.FormatInteger(row["AccessUserID"]); } } } }
Public Class DatabaseCreateDataTable Public Sub DataTableSample() 'Create DataTable on the default database Dim myDataTable As DataTable = Database.CreateDataTable("SELECT TOP 10 * FROM Page") 'Loop rows in DataTable For Each row As DataRow In myDataTable.Rows() Dim pageId As Integer = Input.FormatInteger(row.Item("PageID")) Next 'Create DataTable on alternate database Dim myDataTable2 As DataTable = Database.CreateDataTable("SELECT TOP 10 * FROM AccessUser", "Access.mdb") 'Loop rows in DataTable For Each row As DataRow In myDataTable.Rows() Dim userID As Integer = Input.FormatInteger(row.Item("AccessUserID")) Next 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