Table exists

F

Flying Whiz

Hi,

I am trying to write function Table exists.Hw can I write this in
..netcf.

I am trying to write this fucntion similarly as it was written in eVB
as below.I want to know what dictionary wordS I can use for ADOCE /
ADOCXE.Catalog 3.1 when i am writing this in .NETCF.

Private Function TableExists(paramcnADO As ADOCE.Connection,
paramTableName As String) As Boolean
Dim catTable As ADOXCE.Table
Dim cat As ADOXCE.Catalog

TableExists = False
Set cat = CreateObject("ADOXCE.Catalog.3.1")
cat.ActiveConnection = paramcnADO
For Each catTable In cat.Tables
If InStr(1, catTable.Name, paramTableName) <> 0 Then _
TableExists = True
Next
Set catTable = Nothing
Set cat = Nothing

End Function

Thanks
 
A

Alex Feinman [MVP]

In SQL CE you use a query:
Select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'mytable'
An easy way to use this is something like this:

Dim sqlConn as new SQLCeConnection(connstr)
Dim cmd as SqlCeCommand = sqlConn.CreateCommand()
cmd.CommandText = "Select count(*) from INFORMATION_SCHEMA.TABLES where
TABLE_NAME = 'myTable'"
Dim tableExists = CInt(cmd.ExecuteScalar()) > 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top