日期:2014-05-18 浏览次数:20797 次
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); } } } }
推荐阅读更多>
- 。如何断开。所有正访问。本机共享。资源。的连接。通过。计算机管理。可以,但是C#如何断
- 如果读取app.config的内容,该如何处理
- 继续询问串口发送数据有关问题
- IIS7.5,framework4.0发布网站,不定时出现Object reference not set to an instance of an objec解决方法
- 水晶报表中,去掉结果的重复行解决方法
- c#能否从注册表中准确得出例如迅雷等的安装路径?该怎么解决
- 关于流的有关问题
- C# 全屏实现,该怎么处理
- listview 项文本碰到运算符就会换行如何破?
- WPF怎么实现点击Button后背景色变成红色,再次点击变回原来颜色
- 同样的命令,在窗体的创建中执行,不能得到正确结果,有图!该怎么处理
- C#中判断某个枚举值是否在枚举集合中(以判断文件属性为例),该怎么处理
- 如何把自定义空间放到panel中
- 怎样让执行拖放的时候窗体不会出现"假死"解决方案
- 截取字符串有关问题,请高手帮忙
- C# C/S应用程序 反序列化时出错 异常源是mscorlib
- 支持工作流的业务系统如何弄啊wf行吗
- .net程序没法启动,程序正常初始化失败0x000007b
- 怎么恢复属性
- 数据库中存储过程的返回值怎么在C#中调用