将DB查询数据显示为表

时间:2022-04-27 12:47:33

I am bit new to C#. I am working on a Database application and I need to execute a query say a SELECT and load it in to some sort of table view. Then I want to double click on a result and get it loaded to my original data entry form. Can someone tell me the way that I should follow? Dont waste your time to add coding etc. Simply the steps would be enough. A link to a good resource is also be OK :)

我对C#有点新鲜。我正在处理数据库应用程序,我需要执行一个查询说一个SELECT并将其加载到某种表视图中。然后我想双击结果并将其加载到我的原始数据输入表单。有人可以告诉我应该遵循的方式吗?不要浪费你的时间来添加编码等。简单的步骤就足够了。一个好资源的链接也可以:)

4 个解决方案

#1


4  

Have a look at SqlCommand, SqlDataAdapter and DataTable to retrieve data from the DB. Assuming SQL server, otherwise other DB providers are also available and implement the same API.

看看SqlCommand,SqlDataAdapter和DataTable从数据库中检索数据。假设SQL服务器,否则其他数据库提供程序也可用并实现相同的API。

For Window Forms look at DataGridView, you can bind a DataTable to it and it will display the data in the DataTable

对于Window Forms,请查看DataGridView,您可以将DataTable绑定到它,它将在DataTable中显示数据

You can find an example over here

你可以在这里找到一个例子

#2


1  

Loot at some samples:

抢点一些样品:

Future Readings:

  • Data Access Application Block @MSDN
  • 数据访问应用程序块@MSDN

  • Various Object Relational Mappers (LinqToSQL, Entity Framework, NHibernate etc)
  • 各种对象关系映射器(LinqToSQL,实体框架,NHibernate等)

#4


0  

ADO.NET

SUMMARY: ADO.NET is a data-access technology that enables applications to connect to data stores and manipulate data contained in them in various ways. It is based on the .NET Framework and it is highly integrated with the rest of the Framework class library. The ADO.NET API is designed so it can be used from all programming languages that target the .NET Framework, such as Visual Basic, C#, J# and Visual C++.

摘要:ADO.NET是一种数据访问技术,它使应用程序能够以各种方式连接到数据存储并操纵其中包含的数据。它基于.NET Framework,并与Framework类库的其余部分高度集成。 ADO.NET API的设计使其可以用于所有面向.NET Framework的编程语言,例如Visual Basic,C#,J#和Visual C ++。

#1


4  

Have a look at SqlCommand, SqlDataAdapter and DataTable to retrieve data from the DB. Assuming SQL server, otherwise other DB providers are also available and implement the same API.

看看SqlCommand,SqlDataAdapter和DataTable从数据库中检索数据。假设SQL服务器,否则其他数据库提供程序也可用并实现相同的API。

For Window Forms look at DataGridView, you can bind a DataTable to it and it will display the data in the DataTable

对于Window Forms,请查看DataGridView,您可以将DataTable绑定到它,它将在DataTable中显示数据

You can find an example over here

你可以在这里找到一个例子

#2


1  

Loot at some samples:

抢点一些样品:

Future Readings:

  • Data Access Application Block @MSDN
  • 数据访问应用程序块@MSDN

  • Various Object Relational Mappers (LinqToSQL, Entity Framework, NHibernate etc)
  • 各种对象关系映射器(LinqToSQL,实体框架,NHibernate等)

#3


#4


0  

ADO.NET

SUMMARY: ADO.NET is a data-access technology that enables applications to connect to data stores and manipulate data contained in them in various ways. It is based on the .NET Framework and it is highly integrated with the rest of the Framework class library. The ADO.NET API is designed so it can be used from all programming languages that target the .NET Framework, such as Visual Basic, C#, J# and Visual C++.

摘要:ADO.NET是一种数据访问技术,它使应用程序能够以各种方式连接到数据存储并操纵其中包含的数据。它基于.NET Framework,并与Framework类库的其余部分高度集成。 ADO.NET API的设计使其可以用于所有面向.NET Framework的编程语言,例如Visual Basic,C#,J#和Visual C ++。