Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
O objeto DataSet é central para dar suporte a cenários de dados distribuídos e desconectados com ADO.NET. O objeto DataSet é uma representação de dados residente na memória que fornece um modelo de programação relacional consistente, independentemente da fonte de dados. Ele pode ser usado com várias fontes de dados diferentes, com dados XML ou para gerenciar dados locais para o aplicativo. O objeto DataSet representa um conjunto completo de dados, incluindo tabelas, restrições e relações relacionadas entre as tabelas. Devido à versatilidade do objeto DataSet no armazenamento e exposição de dados, seus dados geralmente podem ser processados e transformados em um objeto DataSet antes de qualquer relatório sobre esses dados ocorrer.
Com as extensões de processamento de dados do Reporting Services, você pode integrar quaisquer objetos DataSet personalizados criados por aplicativos externos. Para fazer isso, você cria uma extensão de processamento de dados personalizada no Reporting Services que atua como uma ponte entre o objeto DataSet e o servidor de relatório. A maior parte do código para processar esse objeto DataSet está contida na classe DataReader que você cria.
A primeira etapa para expor o objeto DataSet ao servidor de relatório é implementar um método específico do provedor em sua classe DataReader que possa preencher um objeto DataSet . O exemplo a seguir mostra como carregar dados estáticos em um objeto DataSet usando um método específico do provedor em sua classe DataReader .
'Private members of the DataReader class
Private m_dataSet As System.Data.DataSet
Private m_currentRow As Integer
'Method to create a dataset
Friend Sub CreateDataSet()
' Create a dataset.
Dim ds As New System.Data.DataSet("myDataSet")
' Create a data table.
Dim dt As New System.Data.DataTable("myTable")
' Create a data column and set various properties.
Dim dc As New System.Data.DataColumn()
dc.DataType = System.Type.GetType("System.Decimal")
dc.AllowDBNull = False
dc.Caption = "Number"
dc.ColumnName = "Number"
dc.DefaultValue = 25
' Add the column to the table.
dt.Columns.Add(dc)
' Add 10 rows and set values.
Dim dr As System.Data.DataRow
Dim i As Integer
For i = 0 To 9
dr = dt.NewRow()
dr("Number") = i + 1
' Be sure to add the new row to the DataRowCollection.
dt.Rows.Add(dr)
Next i
' Fill the dataset.
ds.Tables.Add(dt)
' Use a private variable to store the dataset in your
' DataReader.
m_dataSet = ds
' Set the current row to -1.
m_currentRow = - 1
End Sub 'CreateDataSet
// Private members of the DataReader class
private System.Data.DataSet m_dataSet;
private int m_currentRow;
// Method to create a dataset
internal void CreateDataSet()
{
// Create a dataset.
System.Data.DataSet ds = new System.Data.DataSet("myDataSet");
// Create a data table.
System.Data.DataTable dt = new System.Data.DataTable("myTable");
// Create a data column and set various properties.
System.Data.DataColumn dc = new System.Data.DataColumn();
dc.DataType = System.Type.GetType("System.Decimal");
dc.AllowDBNull = false;
dc.Caption = "Number";
dc.ColumnName = "Number";
dc.DefaultValue = 25;
// Add the column to the table.
dt.Columns.Add(dc);
// Add 10 rows and set values.
System.Data.DataRow dr;
for(int i = 0; i < 10; i++)
{
dr = dt.NewRow();
dr["Number"] = i + 1;
// Be sure to add the new row to the DataRowCollection.
dt.Rows.Add(dr);
}
// Fill the dataset.
ds.Tables.Add(dt);
// Use a private variable to store the dataset in your
// DataReader.
m_dataSet = ds;
// Set the current row to -1.
m_currentRow = -1;
}
public bool Read()
{
m_currentRow++;
if (m_currentRow >= m_dataSet.Tables[0].Rows.Count)
{
return (false);
}
else
{
return (true);
}
}
public int FieldCount
{
// Return the count of the number of columns, which in
// this case is the size of the column metadata
// array.
get { return m_dataSet.Tables[0].Columns.Count; }
}
public string GetName(int i)
{
return m_dataSet.Tables[0].Columns[i].ColumnName;
}
public Type GetFieldType(int i)
{
// Return the actual Type class for the data type.
return m_dataSet.Tables[0].Columns[i].DataType;
}
public Object GetValue(int i)
{
return m_dataSet.Tables[0].Rows[m_currentRow][i];
}
public int GetOrdinal(string name)
{
// Look for the ordinal of the column with the same name and return it.
// Returns -1 if not found.
return m_dataSet.Tables[0].Columns[name].Ordinal;
}
Depois de criar ou recuperar seu conjunto de dados, você pode usar o objeto DataSet em suas implementações dos membros Read, GetValue, GetName, GetOrdinal, GetFieldType e FieldCount da classe DataReader .
Consulte Também
Extensões do Reporting Services
Implementar uma extensão de processamento de dados
Biblioteca de extensões do Reporting Services