使用c#从sql检索数据 [英] retrieving data from sql using c#

查看:78
本文介绍了使用c#从sql检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是visualstudio.net的新手。我练习使用带有c#的asp.net构建网站。我对数据对象,如datareader,dataadapter,dataset感到困惑。如何执行查询。如何逐行使用c#.net访问sql中的数据..请帮帮我...

推荐答案

使用SqlDataAdapter和Dataset

Use of SqlDataAdapter and Dataset
SqlCommand cmd = new SqlCommand("your command ", con);
        
        cmd.CommandType = CommandType.Text;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList2.DataSource = ds;
        DataList2.DataBind();



告诉我你是不是


tell me if you got it


你可以使用ADO.Net 。

You can use ADO.Net for it.

ADO.NET是一组向.NET程序员公开数据访问服务的类。 ADO.NET为编写托管代码的开发人员提供了类似于ADO向本机COM开发人员提供的功能的功能。 ADO.NET提供对Microsoft®SQLServer™等数据源的一致访问,以及通过OLE DB和XML公开的数据源。数据共享使用者应用程序可以使用ADO.NET连接到这些数据源并检索,操作和更新数据。

ADO.NET is a set of classes that expose data access services to the .NET programmer. ADO.NET provides functionality to developers writing managed code similar to the functionality provided to native COM developers by ADO. ADO.NET provides consistent access to data sources such as Microsoft® SQL Server™, as well as data sources exposed through OLE DB and XML. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve, manipulate, and update data.



您可以在Internet上找到很多文章。这里有一些链接可以解释通过C#访问SQL Server的基础知识。

初学者指南,通过C#访问SQL Server [ ^ ]

为初学者使用ADO.NET [ ^ ]

ADO.NET基础知识 [ ^ ]

ADO.NET中的基本数据库操作 [ ^ ]

C#Station ADO.NET教程 [ ^ ]

视频文章:如何添加,保存和播放使用C#编程& amp;检索SQL Server中的数据Visual Studio [ ^ ]





- Amit


A lots of article you can find on internet. Here are some link which will explain you the basics of accessing SQL Server through C#.
Beginners guide to accessing SQL Server through C#[^]
Using ADO.NET for beginners[^]
ADO.NET Basics[^]
Basic Database Operations in ADO.NET[^]
The C# Station ADO.NET Tutorial[^]
Video Article : How to Add, save & retrieve data in SQL Server using C# programming & Visual Studio[^]


--Amit


通过以下内容探讨ADO.NET。



1. [MSDN] ADO.NET [ ^ ]。

2. [MSDN] ADO.NET代码示例 [ ^ ]。

3. ADO.NET课程 [ ^ ]
Go through the below to explore on ADO.NET.

1. [MSDN] ADO.NET[^].
2. [MSDN] ADO.NET Code Examples[^].
3. ADO.NET Lessons[^]


这篇关于使用c#从sql检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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