C# SQL Server和Visual Studio 2012
我已经使用数据连接服务器资源管理器连接到了我的数据库,该资源管理器也添加到了我的web.config中。现在有人能告诉我如何查询吗?当然,您可以这样做:C# SQL Server和Visual Studio 2012,c#,.net,ado.net,C#,.net,Ado.net,我已经使用数据连接服务器资源管理器连接到了我的数据库,该资源管理器也添加到了我的web.config中。现在有人能告诉我如何查询吗?当然,您可以这样做: using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["key_of_element"])) { c.Open(); using (SqlCommand cmd = new SqlCommand("SELECT * FR
using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["key_of_element"]))
{
c.Open();
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Table"))
{
var reader = cmd.ExecuteReader();
while (reader.Read())
{
// do something with the data
}
}
}
本网站上许多问题的副本,