ADO.Net Excel, checking if a table exists?

I am using ADO.Net to work with an Excel document. Basically, I go through the values ​​in a table named "source" and create a new table named "result" that will populate with the results of my query.

I have a few questions.

  • A) How can I check if a table exists and create a new one if it doesn't?
  • B) Is the table the same as the sheet in Excel?

I am working from this example. http://support.microsoft.com/kb/316934#10

+1


a source to share


1 answer


Here is my best solution so far.



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

      

+1


a source







All Articles