当前位置:网站首页>visualstudio 和sql
visualstudio 和sql
2022-06-30 12:46:00 【CSDN问答】
有哪位巨佬知道错lable16的值为什么不显示吗
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace staffmanager
{
public partial class Main1 : Form
{
public Main1()
{
InitializeComponent();
}
string Id;
public void GetId(string id)
{
label16.Text = id;
label16.Refresh();
Id = id;
}
internal void GetENo(string username)
{
throw new NotImplementedException();
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { } private void label7_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { Application.Exit(); } private void Main1_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“managementDataSet.Employee_info”中。您可以根据需要移动或删除它。 this.employee_infoTableAdapter.Fill(this.managementDataSet.Employee_info); string name, sex, dept, tel; string connString = "Data Source=DESKTOP-0M0CC8Q;Initial Catalog=management;Integrated Security=True";//数据库连接字符串 SqlConnection conn = new SqlConnection(connString);//创建connection对象 conn.Open();//打开数据库 //创建数据库命令 SqlCommand cmd = conn.CreateCommand(); //创建查询语句 cmd.CommandText = "select * from Employee_info where ENo ='" + Id + "'"; //从数据库中读取数据流存入reader中 SqlDataReader reader = cmd.ExecuteReader(); //从reader中读取下一行数据,如果没有数据,reader.Read()返回flase while (reader.Read()) { name = reader.GetString(reader.GetOrdinal("Ename")); sex = reader.GetString(reader.GetOrdinal("Esex")); tel = reader.GetString(reader.GetOrdinal("EPhone")); dept = reader.GetString(reader.GetOrdinal("DNo")); label7.Text = name; label7.Refresh(); label8.Text = sex; label10.Text = tel; label9.Text = dept; break; } reader.NextResult();//执行下一句操作 reader.Close(); } private void tabPage2_Click(object sender, EventArgs e) { } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { }}
边栏推荐
- Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
- Dark horse notes - common date API
- RK356x U-Boot研究所(命令篇)3.2 help命令的用法
- Basics of golang -- the difference between slicing and array
- Tronapi wave field interface PHP version - interface document attached - package based on thinkphp5 - source code without encryption - can be opened in two - detailed guidance of the author - 11:49:56
- DeFi“钱从哪来”?一个大多数人都没搞清楚的问题
- JS method of changing two-dimensional array to one-dimensional array
- Apache Doris Compaction优化百科全书
- Unity脚本的基础语法(1)-游戏对象的常用操作
- Qt读写Excel--QXlsx工作表显示/隐藏状态设置4
猜你喜欢

postman 自動生成 curl 代碼片段

一篇文章读懂关于企业IM的所有知识点

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?

Rk356x u-boot Institute (command section) 3.3 env related command usage

这个编辑器即将开源!

逆向调试入门-PE中的VA与RVA换算04/07

【C语言深度解剖】float变量在内存中存储原理&&指针变量与“零值”比较

独立站即web3.0,国家“十四五“规划要求企业建数字化网站!

今日睡眠质量记录80分

App wechat payment unicloud version of uniapp payment (with source code)
随机推荐
ffmpeg 杂项
Unity脚本的基础语法(5)-向量
你想要的异常知识点都在这里了
elementui中清除tinymce富文本缓存
Today's sleep quality record 80 points
这个编辑器即将开源!
深度长文探讨Join运算的简化和提速
On the simplification and acceleration of join operation
防火墙基础之总部双机热备与分支基础配置
产品经理专业知识50篇(七)-如何建立一套完整的用户成长体系?
mqtt-ros模拟发布一个自定义消息类型
Charles break point modify request data & response data
为基础性语言摇旗呐喊
kubeedge的核心理念
Qt中的数据库使用
60 divine vs Code plug-ins!!
Derivation of Park transformation formula for motor control
QT read / write excel--qxlsx worksheet display / hide status setting 4
逆向调试入门-PE中的VA与RVA换算04/07
基于ThinkPHP5封装tronapi-波场接口-PHP版本--附接口文档-20220627