【发布时间】:2017-01-26 20:20:36
【问题描述】:
有人可以帮帮我吗? 我只是得到结果 tb_localidade: System.Data.SqlClient.SqlDataReader
为什么?代码如下:
private void btn_normalizar_Click(object sender, EventArgs e)
{
//connection string - one or other doenst work
//SqlConnection conn = new SqlConnection("DataSource=FRANCISCO_GP;Initial Catalog=Normalizacao;Integrated Security=True;");
SqlConnection conn = new SqlConnection(Properties.Settings.Default.connString);
string sql = "SELECT ART_DESIG from Arterias where ART_COD = '10110'";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader leitor = cmd.ExecuteReader();
tb_localidade.Text = leitor.ToString();
conn.Close();
}
【问题讨论】:
-
您是否搜索过有关如何使用 DataReader 的示例?周围有很多,没有一个使用 ToString 来检索记录的内容
-
请阅读How to Ask并编辑您的标题和正文
-
你真正想要的是 ExecuteScalar。
标签: c# .net sql-server