Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
the select statement is not running 

public partial class FM_Mini_Products : Form
{
    SqlConnection sqlcon = new SqlConnection(@"Server=ADMIN-PC\SQLEXPRESS;Database=ELMANAR; Integrated Security = True");
    SqlDataAdapter da;
        
    DataTable dt1 = new DataTable();
       
    Presintaion_Layer.FM_TBL_Invoice inv = new FM_TBL_Invoice();
    Data_Access_Layer.DataAccessLayer DAL = new Data_Access_Layer.DataAccessLayer();
      
    SqlCommand cmd = new SqlCommand();

    public FM_Mini_Products()
    {
        InitializeComponent();

        da = new SqlDataAdapter("SELECT pr.id_product as 'NO',pr.name_product as 'Name',pr.sale as 'SAle',pr.Qty as 'Qty',s.store_name as 'Store' from TBL_Products  pr inner join TBL_Store as s on s.fk_id = pr.fk_idStore         where s.store_name like '%" + inv.comboStore.Text + "%'" , sqlcon);

            da.Fill(dt1);
            dataGridView1.DataSource = dt1;
          
    }
Posted
Updated 5-Jan-15 23:40pm
v3
Comments
Tejas Vaishnav 6-Jan-15 4:59am    
And what was the problem, what error you got, can you please add more detail about your problem, we can not identify your problem with just seen you code.
Arjsrya 6-Jan-15 5:02am    
what error are you getting?Better create a store procedure and Pass a parameter value from applicaiton to the Store procedure.
CHill60 6-Jan-15 5:48am    
What do you mean by "not running" - do you mean it is not returning any records? Check the content of comboStore.Text - do you actually have any records that match it? (as an aside you should use parameterised queries, don't just insert user entered data directly into a query like that)

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