怎样根据TextBox中的内容查询并显示数据库里的记录? 求解 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SqlConnection conn = new SqlConnection("数据库连接字符串");string sql = " select * from 表 where 字段='" + textbox1.text + "'";//根据textbox中的text动态生成sql语句SqlDataAdapter dr = new SqlDataAdapter(sql, conn);DataTable dt = new DataTable();dr.Fill(dt);this.datagridview1.datasource = dt; SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=MH\SQLEXPRESS;Initial Catalog=hs;User Id=sa;Password=;"; con.Open(); SqlDataAdapter adapter = new SqlDataAdapter("select * from BillList where code='"+textBox1.Text+"'",con); DataSet ds = new DataSet(); adapter.Fill(ds, "BillList"); dataGridView1.DataSource = ds.Tables["BillList"]; SqlConnection conn = new SqlConnection("数据库连接字符串");string sql = textbox1.text //根据textbox中的text动态生成sql语句SqlDataAdapter dr = new SqlDataAdapter(sql, conn);DataTable dt = new DataTable();dr.Fill(dt);this.datagridview1.datasource = dt;或者是这样 http://blog.csdn.net/xianfajushi/article/details/7643705 你好,现在的错误的提示信息是 当前上下文中并不包含“dataGridView”的定义 哥,你拖个dataGridView控件到窗体行不? dataGridView是用来做数据显示的,你在页面上要要有dataGridView。 是B/S吧?拖个gridview控件过去。 一道中学数学竞赛题! 如何在DataGridView里显示两个表中的内容? 如何控制datagridview中从数据库读回来的内容的排列顺序 数据库怎么打包 RESOURCE文件 请问哪里有.net 的最新中文版下载?地址要正确 请教:从任意位置直接退出整个程序用哪个?return?谢谢! 请问如何添加dll文件 怎么样让自定义组件类在调用时得到中文提示信息! 帮忙有益健康(在线等待) 如何在dataset中手动插入1条数据?? 菜鸟求助web导出到excel的问题
string sql = " select * from 表 where 字段='" + textbox1.text + "'";//根据textbox中的text动态生成sql语句SqlDataAdapter dr = new SqlDataAdapter(sql, conn);
DataTable dt = new DataTable();
dr.Fill(dt);
this.datagridview1.datasource = dt;
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=MH\SQLEXPRESS;Initial Catalog=hs;User Id=sa;Password=;";
con.Open();
SqlDataAdapter adapter = new SqlDataAdapter("select * from BillList where code='"+textBox1.Text+"'",con);
DataSet ds = new DataSet();
adapter.Fill(ds, "BillList");
dataGridView1.DataSource = ds.Tables["BillList"];
string sql = textbox1.text //根据textbox中的text动态生成sql语句SqlDataAdapter dr = new SqlDataAdapter(sql, conn);
DataTable dt = new DataTable();
dr.Fill(dt);
this.datagridview1.datasource = dt;
或者是这样
dataGridView是用来做数据显示的,你在页面上要要有dataGridView。
拖个gridview控件过去。