C#实现在sql查找数据显示在label控件上。
才开始学,不懂就问。
2条回答 默认 最新
- CSDN专家-sinJack 2021-08-13 10:26关注
label.text = 你的变量名.ToString() 变量的值显示在标签上
如有帮助,望点击【本回答采纳】支持一下。
案例:SqlConnection sqlconn = new SqlConnection(); sqlconn.ConnectionString = ; sqlconn.Open(); SqlCommand cmd = sqlconn.CreateCommand(); cmd.CommandText = select 职务 from 用户信息 where 账号 = '7'; SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); string temp_role = reader.GetString(0); sqlconn.Close(); Label1.Text = temp_role;
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 3无用