如何从C#中的数据库中读取行? [英] How to Read a row from database in C#?

查看:441
本文介绍了如何从C#中的数据库中读取行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像INSERT,DELETE和UPDATE语句一样,是否有任何语句从数据库读取数据?我正在使用Visual Studio 2008和SQL Server2008.我想从数据库的一行中读取一个元素.我已经在网上搜索过,但是那里的代码是cs文件.但是我想要aspx文件的代码.在此先感谢.

Like INSERT,DELETE AND UPDATE statements,is there any statement to read data from database? I am using visual studio 2008 and sql server 2008. I want to read an element from a row of a database. I have searched on net but the code there is of cs file. but i want code of aspx file. Thanks in advance.

推荐答案

如果您无法从数据库中读取数据,数据库会有什么好处?这是一个SELECT查询.

那里有数以百万计的示例,还有许多其他不同的实现方法.

ASPX只是ASP.NET应用程序中的页面. .cs文件是C#代码文件.在ASP.NET应用程序和普通的Windows Forms应用程序中执行此操作之间没有区别,二者均使用C#编写.

让我让您开始使用简单的Google查询-> [ ^ ]
What good would a database be if you couldn''t read data from it?? It''s a SELECT query.

There''s millions upon millions of examples on this out there and more than a few different ways to do it.

ASPX is just a page from an ASP.NET application. A .cs file is a C# code file. There is no difference between doing this operation in an ASP.NET app and a normal Windows Forms app, either of which is written in C#.

Let me get you started wit ha simple Google query -> "C# get data from database"[^]


ummm ... sqldatareader和sqldataadapter是两种方法,一种是连接的,而另一种是断开连接的体系结构.您可以在网上找到有关ado.net,linq和其他数据库程序交互方式的示例
ummm...sqldatareader and sqldataadapter are two approaches, one connected and other is disconnected architecture. you can find examples for both around the web for ado.net, linq and other means of db-program interaction


这篇关于如何从C#中的数据库中读取行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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