Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SQL Server和Visual Studio 2012_C#_.net_Ado.net - Fatal编程技术网

C# SQL Server和Visual Studio 2012

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

我已经使用数据连接服务器资源管理器连接到了我的数据库,该资源管理器也添加到了我的web.config中。现在有人能告诉我如何查询吗?

当然,您可以这样做:

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
        }
    }
}

本网站上许多问题的副本,