Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
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 7:03am
Edited 21-Jan-13 7: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
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 429
2 OriginalGriff 360
3 CHill60 280
4 Sascha Lefévre 269
0 Sergey Alexandrovich Kryukov 10,017
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076

Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2015
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