Il blog di Giuseppe Marchi - SharePoint MVP
NAVIGATION - SEARCH

Metodo DisplayDataSetStructure

Metodo semplice semplice per stampare a video la struttura di un oggetto di tipo DataSet:

C#
static void DisplayDataSetStructure(DataSet ds)

{
Console.WriteLine("DataSet structure+\n")
for(int j=0; j<ds.Tables.Count; j++)
{
Console.WriteLine("\tTable name: "+ds.Tables[j].TableName+"\n")
for(int i=0; i<ds.Tables[0].Columns.Count; i++)
{
Console.Write("\t\tColumn name: "+ds.Tables[0].Columns[i].ColumnName);
Console.WriteLine(" ("+ds.Tables[0].Columns[i].DataType.ToString()+")\n");
}
}
}

VB.NET
Shared Sub DisplayDataSetStructure(ByVal ds As DataSet)


Console.WriteLine("DataSet structure" & vbLf)
Dim j As Integer
Dim i As Integer
Do While (j < ds.Tables.Count)

Console.WriteLine(vbTab & "Table name: "+ds.Tables(j).TableName & vbLf)
Do While (i < ds.Tables.Count)

Console.Write(vbTab & vbTab & "Column name: "+ds.Tables[0].Columns[i].ColumnName);
Console.WriteLine(" (" & ds.Tables[0].Columns[i].DataType.ToString()&")" & vbLf);
i = i + 1
Loop
j = j + 1
Loop

End Sub
blog comments powered by Disqus