DataSet s = null; if (s.Tables.Contains("product")) { //todo }
示例 [Visual Basic, C#] 以下示例测试 DataTableCollection 中是否存在名为“Suppliers”的表。[Visual Basic] Private Sub TestForTableName() Dim dSet As DataSet ' Get the DataSet of a DataGrid. dSet = CType(DataGrid1.DataSource, DataSet) ' Get the DataTableCollection through the Tables property. Dim tablesCol As DataTableCollection tablesCol = dSet.Tables ' Check if the named table exists. If tablesCol.Contains("Suppliiers") Then MessageBox.Show("Table named Suppliers exists") End If End Sub[C#] private void TestForTableName() { DataSet dSet; // Get the DataSet of a DataGrid. dSet = (DataSet)DataGrid1.DataSource; // Get the DataTableCollection through the Tables property. DataTableCollection tablesCol = dSet.Tables; // Check if the named table exists. if (tablesCol.Contains("Suppliiers")) MessageBox.Show("Table named Suppliers exists"); }
if (s.Tables.Contains("product"))
{
//todo
}
[Visual Basic, C#] 以下示例测试 DataTableCollection 中是否存在名为“Suppliers”的表。[Visual Basic]
Private Sub TestForTableName()
Dim dSet As DataSet
' Get the DataSet of a DataGrid.
dSet = CType(DataGrid1.DataSource, DataSet)
' Get the DataTableCollection through the Tables property.
Dim tablesCol As DataTableCollection
tablesCol = dSet.Tables
' Check if the named table exists.
If tablesCol.Contains("Suppliiers") Then
MessageBox.Show("Table named Suppliers exists")
End If
End Sub[C#]
private void TestForTableName()
{
DataSet dSet;
// Get the DataSet of a DataGrid.
dSet = (DataSet)DataGrid1.DataSource;
// Get the DataTableCollection through the Tables property.
DataTableCollection tablesCol = dSet.Tables;
// Check if the named table exists.
if (tablesCol.Contains("Suppliiers"))
MessageBox.Show("Table named Suppliers exists");
}