Click here to Skip to main content
13,042,421 members (82,005 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everyone!

What is the best way to obtain a list of user defined tables?
I would like to add them to a combo box in my program.

Here is what I have so far:
SqlCeCommand getTables_comm = new SqlCeCommand("SELECT table_name from user_tables", conn);
getTables_comm.CommandType = CommandType.Text;

conn is defined as the connection to the database.

The following error is what I'm receiving as a result of running this code:
An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll.

This error is pointing to the ExecuteNonQuery command.

Does anyone have any advice as to what I'm doing wrong and how to resolve this sqlserver error message?
Posted 21-Jan-13 6:03am
Updated 21-Jan-13 6:11am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It returns all table names in the database.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Specifically include the name of the database (as well as the schema if possible like:
USE [database]
SELECT * FROM sys.tables WHERE [type] = 'U'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100