SQL Server和Visual Studio 2012
答
当然,你可以这样做:在这个网站
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
}
}
}
重复的很多问题.... http://stackoverflow.com/questions/9966301/sql-query-form-c-sharp, http://stackoverflow.com/questions/783294/executing-an-sql-statement-in-c,http://stackoverflow.com/questions/1504895/simple-sql-select-in-c –