主题:[讨论][求助]sql数据库查询出现的问题
妈妈的,先提示我什么存储过程每定义@sale_id字段,我七改八改...又它妈的什么也
不提示....
我不就是要做个组合查询吗,就那么费劲,我就日了.....
textBox1里面输入编号
textBox2里面输入姓名
comboBox1选择籍贯
我日...就他妈的不行....
---------------------------------------------
这是我的存储过程:
CREATE PROCEDURE getallczyinfo
(
@sale_id char(10) ,
@sale_name char(10),
@sale_jg char(10)
)
AS
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 =@sale_id and sale_name = @sale_name and sale_jg = @sale_jg
GO
-------------------------------
代码是:
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";
comboBox1.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text == "")
myda.SelectCommand.Parameters["@sale_id"].Value = "%";
else
myda.SelectCommand.Parameters["@sale_id"].Value = textBox1.Text;
if (textBox2.Text == "")
myda.SelectCommand.Parameters["@sale_name"].Value = "%";
else
myda.SelectCommand.Parameters["@sale_name"].Value = textBox2.Text;
if (comboBox1.SelectedIndex == 0)
myda.SelectCommand.Parameters["@sale_jg"].Value = "%";
else
myda.SelectCommand.Parameters["@sale_jg"].Value = comboBox1.SelectedItem;
myds.Tables["salepeople"].Clear();
myda.Fill(myds, "salepeople");
}
catch (SqlException ee) { MessageBox.Show(ee.Message); }
}
---------------
我TMD按button1怎么就是没反应呢?????
不提示....
我不就是要做个组合查询吗,就那么费劲,我就日了.....
textBox1里面输入编号
textBox2里面输入姓名
comboBox1选择籍贯
我日...就他妈的不行....
---------------------------------------------
这是我的存储过程:
CREATE PROCEDURE getallczyinfo
(
@sale_id char(10) ,
@sale_name char(10),
@sale_jg char(10)
)
AS
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 =@sale_id and sale_name = @sale_name and sale_jg = @sale_jg
GO
-------------------------------
代码是:
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";
comboBox1.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text == "")
myda.SelectCommand.Parameters["@sale_id"].Value = "%";
else
myda.SelectCommand.Parameters["@sale_id"].Value = textBox1.Text;
if (textBox2.Text == "")
myda.SelectCommand.Parameters["@sale_name"].Value = "%";
else
myda.SelectCommand.Parameters["@sale_name"].Value = textBox2.Text;
if (comboBox1.SelectedIndex == 0)
myda.SelectCommand.Parameters["@sale_jg"].Value = "%";
else
myda.SelectCommand.Parameters["@sale_jg"].Value = comboBox1.SelectedItem;
myds.Tables["salepeople"].Clear();
myda.Fill(myds, "salepeople");
}
catch (SqlException ee) { MessageBox.Show(ee.Message); }
}
---------------
我TMD按button1怎么就是没反应呢?????