【问题标题】:ADO.Net Excel, Checking if a table exists?ADO.Net Excel,检查表是否存在?
【发布时间】:2009-05-14 17:32:16
【问题描述】:

我正在使用 ADO.Net 处理 Excel 文档。本质上,我在一个名为“source”的表中查找值并创建一个名为“result”的新表,该表将填充我的查询结果。

我有几个问题..

  • A) 如何检查表是否存在 如果没有则创建一个新的?
  • B) 表是否与表中的工作表相同 Excel?

我正在使用这个示例.. http://support.microsoft.com/kb/316934#10

【问题讨论】:

    标签: .net asp.net vb.net excel ado.net


    【解决方案1】:

    这是我目前最好的解决方案..

    dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
    
    If dt.Rows.Count > 0 Then
        For Each row As DataRow In dt.Rows
            For Each column As DataColumn In dt.Columns
                If row(column).ToString() = "result" Then
                    blnResultTableExists = True
                End If
            Next
        Next
    End If
    

    【讨论】:

      猜你喜欢
      • 2010-11-01
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 2020-09-26
      • 1970-01-01
      • 1970-01-01
      • 2012-06-28
      • 2015-10-18
      相关资源
      最近更新 更多