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