SQL查询返回用户定义的表 [英] SQL query to return user defined tables

查看:93
本文介绍了SQL查询返回用户定义的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



获取用户定义表列表的最佳方法是什么?

我想添加它们到我的程序中的一个组合框。



这是我到目前为止:

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;
getTables_comm.ExecuteNonQuery();



conn 被定义为与数据库的连接。 />


由于运行此代码,我收到以下错误:


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.



此错误指向 ExecuteNonQuery 命令。



有没有人对我做错了什么以及如何解决这个sqlserver错误信息有任何建议?


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?

推荐答案

尝试:

Try:
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES

它返回数据库中的所有表名。

It returns all table names in the database.


具体包括名称数据库(以及可能的架构如:

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


这篇关于SQL查询返回用户定义的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆