有人可以帮我吗? 我只是得到结果tb_localidade:System.Data.SqlClient.SqlDataReader得到结果: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来检索记录的内容 – Steve
请阅读[问]并编辑你的标题和正文 –
你真正想要的是ExecuteScalar。 – LarsTech