日期:2014-05-18 浏览次数:20817 次
CREATE PROCEDURE getallczyinfo ( @sale_id char(10) , @sale_name char(10), @sale_jg char(10) ) AS declare @condition varchar(400) set @condition='' if(rtrim(@sale_id)!='') begin set @condition=@condition+' and sale_id='''+@sale_id+'''' end if(rtrim(@sale_name)!='') begin set @condition=@condition+' and sale_name='''+@sale_name+'''' end if(rtrim(@sale_jg)!='') begin set @condition=@condition+' and sale_jg='''+@sale_jg+'''' end declare @select1 varchar(2000) set @select1='select salepeople.sale_id as 销售员编号,salepeople.sale_name as 销售员姓名,salepeople.sale_sex as 销售员性别, salepeople.sale_age as 销售员年龄, salepeople.sale_jg as 销售员籍贯,salepeople.sale_xl as 销售员学历, salepeople.sale_call as 销售员电话,salepeople.sale_zhz as 销售员住址, salepeople.sale_xst as 销售员柜台 from salepeople where sale_id!=''-1''' exec(@select1+@condition) GO
namespace openjjsys { public partial class salepeoplemanage : Form { public salepeoplemanage() { InitializeComponent(); } private SqlConnection mycn; private SqlCommand mycmd; private SqlDataAdapter myda; private DataSet myds; private void salepeoplemanage_Load(object sender, EventArgs e) { mycn = new SqlConnection(); mycn = new SqlConnection("server=localhost;uid=sa;pwd=;database=openjjsys;"); myds = new DataSet(); mycmd = new SqlCommand(); mycmd.Connection = mycn; mycmd.CommandType = CommandType.StoredProcedure; mycmd.CommandText = "getallczyinfo"; mycmd.Parameters.Add(new System.Data.SqlClient.SqlParameter ("@sale_id",System.Data.SqlDbType.Char,10,"sale_id")); mycmd.Parameters.Add(new System.Data.SqlClient.SqlParameter ("@sale_name", System.Data.SqlDbType.Char, 10, "sale_name")); mycmd.Parameters.Add(new System.Data.SqlClient.SqlParameter ("@sale_jg", System.Data.SqlDbType.Char, 10, "sale_jg")); myda = new SqlDataAdapter(); myda = new SqlDataAdapter("getallczyinfo", mycn); myda.SelectCommand = mycmd; mycmd.Parameters["@sale_id"].Value = "%"; mycmd.Parameters["@sale_name"].Value = "%"; mycmd.Parameters["@sale_jg"].Value = "%"; myda.Fill(myds, "salepeople"); dataGridView1.DataSource = myds; dataGridView1.DataMember = "salepeople"; } private void button1_Click(object sender, EventArgs e) { try { myda.SelectCommand.Parameters["@sale_id"].Value = textBox1.Text; myda.SelectCommand.Parameters["@sale_name"].Value = textBox2.Text; myda.SelectCommand.Parameters["@sale_jg"].Value = comboBox1.SelectedItem; myds.Tables["salepeople"].Clear(); myda.Fill(myds, "salepeople"); } catch (SqlException ee) { MessageBox.Show(ee.Message); } } } }
推荐阅读更多>
- 当 ViewState["dt"] 很大的时分,用什么方式保存比较好
- java聚合框架类源代码阅读体会(Java Collections Framework)
- 如何在这CSDN資源上面下载文檔呢﹖多谢﹗
- 打开多个文档的有关问题
- vs2005项目引用
- 急C#怎样使用正则表达式去掉字符串中所有的html标记,该如何处理
- 向数据库查询,如何获取一列的值存在一个变量里面
- 请问:SendKeys.Send 为什么会随机发送几次
- 各位用.NET为主的朋友,你们的C,C++,数据结构,算法基础,水平怎样呢?面试时遇到过这方面的笔试?怎么应对呢
- 表达式含义^[a-zA-Z0-9\u4E00-\u9FA5]+$
- 请教为什么Debug下面没有.dll文件
- 获取textbox中的值替空,求解决!
- 写个简略的IOC的例子,还是hello World
- 高分怎么判断串口种类
- c#调用pdfcreator批量将word转换成pdf文件解决思路
- 很简单的有关问题,关于主从表,小弟我糊涂了,究竟哪个是主表,哪个是从表,约束如何做
- winform中datagridvoew添加列的有关问题
- ★ 窗体无反应 假死,该如何处理
- dataset公共变量设立后,无法传递
- 在MDI子窗口怎么退出系统