string name = this.TextBox1.text;string sql = "select IndustryId from TABLE1 where IndustryName='"+ name +"'";如何才能取出 IndustryId并存放到一个定义的变量里呢 大侠指点!!(假如我定义一个 int id; 怎么把查询出来的IndustryId存放到id里边呢??)急!
解决方案 »
- c#关于接口增加新方法问题
- 大家请帮帮我找出post方式提交的数据字符串
- 一个语句,大家告诉我怎么写哈
- 求ASP。NET视频教程
- 数据传输出现丢包现象,该如何解决?程序如何捕获到丢包发生了?
- c#--大家帮帮忙
- BOOL BitBlt(HDC hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,HDC hdcSrc,int nXSrc,int nYSrc,DWORD dwRop)最后一个参数问题
- 数据插入
- 我要修改20台交换机密码!能否写程序批量换完!
- 请问一个正则表达式
- 在线求教难题:从配置文件中取出多个方法名及程序集路径,将配置文件中的一组方法挂接到程序的某个事件上。即根据配置文件中的设置动态的绑定到程序的指定的事件上
- owc怎样使用?
楼主应仔细学习一下ado.net的基础知识。
SqlConnection conn = new SqlConnection(connstring);
conn.Open();
string name = this.TextBox1.text; string sql = "select IndustryId from TABLE1 where IndustryName='"+ name +"'"; string id;//要存储的ID变量
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (reader.Read()) {
id = Convert.ToString(reader["IndustryId"]);
}
conn.Close();
conn.Dispose();
就弹出一个对话框 显示 "Industry ";
放在 table 或 reader 里头 ,自己用程序控制咯
C#把啥都封装了,学了C#的大把人还是啥都不懂。毕业久了,你就会知道大学课本教的并不是完全脱离实际一点没用。