【发布时间】:2014-03-27 15:39:37
【问题描述】:
我正在尝试将信息从数据库保存到字符串。
下面的代码怎么可能?
using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("SELECT something FROM table");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
}
是否可以使用它从保存在string 中的数据库中获取一些值?
【问题讨论】:
-
需要单行的值吗?你需要单列的值吗?你的问题有点含糊
标签: c# sql .net sql-server ado.net