SQL查询以显示表的内容 [英] Sql Queries to show contents of the table

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

问题描述

你好,我有问题.
我已经在SQL中创建了一个名为Department
的表 具有以下部门名称
人力资源
计算机科学
MBA

现在我想在Visual Studio 2010的组合框中显示这些部门名称
??

谁能帮我 ?? plz

Hello, I have a problem .
I have created a table in SQL called Department
which has followings departmentNames
HumanResource
ComputerScience
MBA

now i want to show these department names in combo box in visual studio 2010
??

Can any one help me ?? plz

推荐答案

由于您没有更精确地指定问题,因此步骤可能是:
Since you didn''t specify the problem more precisely, the steps could be:

  • fetch the data from db using SqlCommand[^] to a DataTable[^]
  • Set the DisplayMember[^] to proper column name
  • Set the ValueMember[^] if necessary (for example if you have a different key column)
  • define the DataTable[^] as a DataSource[^] for the combo


使用ADO.NET从数据库中获取数据.数据表中包含数据后,请绑定部门名称& id到组合框.

在ADO.NET上查看以下内容:
MSDN:ADO.NET [ MSDN:使用ADO.NET访问数据 [ ^ ]

SQL查询:
Use ADO.NET to get the data from database. Once you have the data in datatable, bind the department name & id to the combobox.

Look at these for ADO.NET:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]

SQL Query:
SELECT 
  departmentnames,
  departmentid
FROM
  Department



要使用的属性:
MSDN:ComboBox.DataSource属性 [ MSDN:ListControl.DisplayMember属性 [ MSDN:ListControl.ValueMember属性 [



Properties to use:
MSDN: ComboBox.DataSource Property[^]
MSDN: ListControl.DisplayMember Property [^]
MSDN: ListControl.ValueMember Property[^]


你好,
您这里的最佳简便解决方案:
sp_helptext [
Hi,
Your easy and best solution here:
sp_helptext[^]


这篇关于SQL查询以显示表的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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