什么是 ADO.NET [英] What is ADO.NET
问题描述
我对 ADO.NET 的理解感到困惑,在阅读了几篇文章后,我不清楚什么是性能考虑.
I puzzled with understanding ADO.NET, after reading several articles I do not have a clear idea what is perfomance consideration.
- 什么是 ADO.NET 以及性能注意事项?
- ADO.NET 可能与 SQL STORED PROCEDURES 相关联还是不同的东西?
谢谢大家!
推荐答案
将 Ado.net 视为一个托管库,它提供了访问外部所需(并且可能使用)的所有类和功能数据源.这是最简单的思考方式.但由于它不是一个单独的库(因为它包含在 .net 库中),人们往往会感到困惑.我们可以说它是 .net 中的一个库.
Think of Ado.net as a managed library that provides all the classes and functionality you need (and may use) to access external data sources. That's the most simplest way of thinking of it. But since it's not a separate library (because it's included with the .net library) people tend to be confused. We could say it's a library inside .net.
可以在 维基百科上找到更详尽的解释.
A more thorough explanation can be found on Wikipedia.
存储过程是特定数据存储的一部分.Ado.net 使您能够以标准化的方式调用这些存储过程.
Stored procedure is part of a particular data store. Ado.net gives you the ability to call these stored procedures in a standardized way.
来自 MSDN 的示例
An example from MSDN
using (SqlConnection connection = new SqlConnection(connectionString))
{
// Create the Command and Parameter objects.
SqlCommand command = new SqlCommand(queryString, connection);
command.Parameters.AddWithValue("@pricePoint", paramValue);
// Open the connection in a try/catch block.
// Create and execute the DataReader, writing the result
// set to the console window.
try
{
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(" {0} {1} {2}", reader[0], reader[1], reader[2]);
}
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
可以看到Ado.net类的使用:
You can see the use of Ado.net classes:
SqlConnection
SqlCommand
和SqlDataReader
所以 Ado.net 为您提供了所有这些,因此您不必每次想要访问外部数据源(关系数据库、服务等)时都重新发明轮子.
So Ado.net has all these provided for you, so you don't have to reinvent the wheel every time you'd like to access external data sources (relational data bases, services etc.).
这篇关于什么是 ADO.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!