' データソースおよびこのデータソースを使用するパラメータを追加します
Dim mds As DataSource = rep.DataSource
Dim ds As New DataSource()
ds.Name = "CategoriesDS"
ds.ConnectionString = mds.ConnectionString
ds.RecordSource = "select * from categories"
ds.DataProvider = DataProvider.OLEDB
rep.DataSources.Add(ds)
mds.RecordSource = "select * from products where categoryid = [CategoryParam]"
Dim rp As New ReportParameter()
rp.DataType = Doc.ParameterType.[Integer]
rp.Prompt = "Category"
rp.Name = "CategoryParam"
rp.AllowedValuesDefinition.Binding.DataSourceName = "CategoriesDS"
rp.AllowedValuesDefinition.Binding.ValueExpression = "CategoryID"
rp.AllowedValuesDefinition.Binding.LabelExpression = "CategoryName"
rep.Parameters.Add(rp)