Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I hava used stimulReport in my program.
I have five comboBoxes and one button in the form. the report button should shows the report according the selected items of ComboBoxs. but it shows all the data in the table.I can underestand what is wrong with the codes???
please help me.

these are the codes:
C#
private void btnReport_Click(object sender, EventArgs e)
 {
    dset.Clear();
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.Text;
    cmd.Connection = cnn;

    cmd.CommandText = "SELECT SerialId,GoodsName,GoodsType,Amval,Radeh,Condition,city,PlaceKeeping FROM tblRegister WHERE city like'" + txtShahrestan.Text.Trim() + "'  AND Radeh like'" + txtRade.Text.Trim() + "' AND GoodsName like'" + txtGoodsName.Text.Trim() + "' AND GoodsType like'" + txtGoodsType.Text.Trim() + "' AND Condition like'" + txtCondition.Text.Trim() + "'  ";


    SqlDataAdapter adpter = new SqlDataAdapter();
    adpter.SelectCommand = cmd;
    adpter.Fill(dset, "tblRegister");
    stiReport1.RegData(dset);
    stiViewerControl1.Report = stiReport1;
    stiReport1.Show();
}
Posted
Updated 22-Apr-11 10:37am
v2

1 solution

One of the problems might be that you are using like rather a lot. If this is intentional it is OK
so long as you realize that "Where City like 'L'" would get London, Leeds, Lincoln, Londonderry, Lieth, Loughton................ etc.
 
Share this answer
 
Comments
setareh_sky 23-Apr-11 0:55am    
it is not the problem.for the thing that you said ,we should use (like '%"+ ..... +"%') which bring the cities have "L" e.x.
by the way, thank you for your solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900