CSharpTest.Net
GetSchemaTable Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetSchemaTable Method

Glossary Item Box

Returns a DataTable which defines the columns in this CSV file

Syntax

Visual Basic (Declaration) 
Public Function GetSchemaTable() As DataTable
C# 
public DataTable GetSchemaTable()

Example

Library/Library.Test/TestCsvReader.cs

C#Copy Code
DataTable dt = new CsvReader(new StringReader(CSV_DOC1)).GetSchemaTable();

Assert.AreEqual(3, dt.Columns.Count);
Assert.AreEqual("f1", dt.Columns[0].ColumnName);
Assert.AreEqual(typeof(String), dt.Columns[0].DataType);
Assert.AreEqual("f2", dt.Columns[1].ColumnName);
Assert.AreEqual(typeof(String), dt.Columns[1].DataType);
Assert.AreEqual("f3", dt.Columns[2].ColumnName);
Assert.AreEqual(typeof(String), dt.Columns[2].DataType);
VB.NETCopy Code
Dim dt As DataTable = New CsvReader(New StringReader(CSV_DOC1)).GetSchemaTable()

Assert.AreEqual(3, dt.Columns.Count)
Assert.AreEqual("f1", dt.Columns(0).ColumnName)
Assert.AreEqual(GetType([String]), dt.Columns(0).DataType)
Assert.AreEqual("f2", dt.Columns(1).ColumnName)
Assert.AreEqual(GetType([String]), dt.Columns(1).DataType)
Assert.AreEqual("f3", dt.Columns(2).ColumnName)
Assert.AreEqual(GetType([String]), dt.Columns(2).DataType)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys