views:

430

answers:

1

I'm using ADO.Net to work with an Excel Document. Essentially, I'm looking up values in a table called "source" and creating a new table called "result" which will be populated with the results of my query.

I have a couple of questions..

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

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

+1  A: 

Here's my best solution as of now..

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
madcolor