Markus said:
I just want to check with "ADO" and "SQLConnection" if a table exist
and what columns the table have. Does somebody know how to do that?
I'm assuming you know how to execute queries using ADO.NET and interpret the
results in DataTables -- if not, take a look in MSDN or search in Google for
information on how to do this.
To find if a table exists in SQL Server, execute the following SQL:
\\\
select *
from INFORMATION_SCHEMA.TABLES
where TABLE_NAME = 'TableName'
and TABLE_TYPE = 'BASE TABLE'
///
(Replace 'TableName' with the name of the table you're looking for). If the
table exists, a row will be returned with details of the table; if it
doesn't exist, no data will be returned.
Once you've determined that the table exists, you can query the columns
within the table as follows:
\\\
select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'TableName'
order by ORDINAL_POSITION
///
This will give you lots of information about the table columns, including
their names, datatypes, max lengths, nullability, default values, etc.
HTH,