Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
H

haroon1980

@haroon1980
About
Posts
48
Topics
19
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • textBoxes Calculation issue
    H haroon1980

    hello, thanks - Iam trying to get the values of all textboxes and then adding it in totaltextbox but currently it takes only current textbox and when it leaves to 2nd it forgets the first one. Any help please?

    private void textBoxes_TextChanged(object sender, EventArgs e)
    {
    TextBox tb = sender as TextBox;
    if (tb != null)
    {
    decimal temp = 0;
    if (decimal.TryParse(tb.Text, out temp))
    {
    if (temp > 1)
    MessageBox.Show("Please enter the nnumber between 0 and 1.");
    }
    }
    }

        private void textBoxes\_Leave(object sender, System.EventArgs e)
        {
            decimal total = 0;
            TextBox tb = sender as TextBox;
            if (tb != null)
            {
                decimal temp = 0;
                if (decimal.TryParse(tb.Text, out temp))
                {
                    total += temp;
                    totalTimetxtBox.Text = total.ToString();
                    
                }
            }
        }
    
    C# help question

  • textBoxes Calculation issue
    H haroon1980

    so any solution to help pleas if possible?

    C# help question

  • textBoxes Calculation issue
    H haroon1980

    yes somehow it fires 2 times - dont know why? i just want to put 0.1 in one textbox,0.2 in 2nd textbox etc and then getting same time my totaltimetxtbox calculates as well

    C# help question

  • textBoxes Calculation issue
    H haroon1980

    Hello, When i use below code - App launches and when entering values it loops two times through my if(tb != null) function - Any idea please? And then somehow my total text box same value twice.

    public Form()
    {
    InitializeComponent();
    TextBox[] tbs = new TextBox[] { monTxtBox, tuesTxtBox, wedTxtBox, thurTxtBox, frdtxtBox };
    foreach (var c in tbs)
    c.TextChanged += new EventHandler(textBoxes_TextChanged); //create a common event for all textBoxes
    }

        private void textBoxes\_TextChanged(object sender, EventArgs e)
        {
            TextBox tb = sender as TextBox;
            if(tb != null)
            {
                decimal temp =0;
                if(decimal.TryParse(tb.Text,out temp))
                {
                    if(temp < 1)
               //     totalTimetxtBox.Text = Convert.ToDecimal(tb.Text.Replace(",",".").ToString())+temp;
                     totalTimetxtBox.Text = tb.Text+temp;
            else
                MessageBox.Show("Please enter the number between 0 and 1.");
                }
        else
            MessageBox.Show("Please enter a decimal value only!");
            }
        }
    
    C# help question

  • Filling gridview with multiple combobox
    H haroon1980

    Hi, I am sorry for some earlier posts as i was bit confused on my design of application... Ok..I have BillDetails,Products,Packing Table... And on winform I have gridview...Now in gridview I want to display billdetails table..but somehow the first two columns need to be combobox..and these combobox should take data from Products Table together with Packing.. I have screen shot as what exist in those tables..Also below is a small code that i have done but i see only one dropdown list with nothing populated... Please HELP..I will really appreciate as i am stuck in it for few days

    :confused:void fillData()
    {
    OleDbConnection database = new OleDbConnection(connectionString);
    database.Open();
    OleDbDataAdapter adapter1 = new OleDbDataAdapter("SELECT BillDetails.ProductID, BillDetails.ProductName, BillDetails.InQty, BillDetails.InBns, BillDetails.InPrice, BillDetails.Dis1, Products.packing, BillDetails.Saletype, BillDetails.SBtype, Products.FactorC, Products.FactorB, BillDetails.Type FROM Products INNER JOIN BillDetails ON Products.ProdID = BillDetails.ProductID", database);
    //OleDbDataAdapter adapter1 = new OleDbDataAdapter("Select Products.ProdID,Products.ProductName,Packing.PackingName,Products.CPrice from Packing INNER JOIN Products ON Packing.PackingID=Products.Packing", database);

            DataGridViewComboBoxColumn dgridcolumn = new DataGridViewComboBoxColumn();
            dgridcolumn.Name = "Products";
            this.dataGridView1.Columns.Add(dgridcolumn);
           
    
            DataTable dt = new DataTable();
            DataTable packDT = new DataTable();
           
            adapter1.Fill(dt);
            dataGridView1.DataSource = dt;
    
            adapter1.Fill(packDT);
            dgridcolumn.DataSource = packDT;
           
            dgridcolumn.ValueMember = packDT.Columns\[1\].ColumnName.ToString();
            
            dgridcolumn.DisplayMember = packDT.Columns\[1\].ColumnName.ToString();
            
           
        }
    
    C# help database design

  • Add data in gridview from multiple tables and combobox [modified]
    H haroon1980

    Any help pls

    C# database help question

  • Add data in gridview from multiple tables and combobox [modified]
    H haroon1980

    Hi, Basically i am trying to make a combobox in 2nd row of gridview... two issues in below function: Two things: 1. Now adapter2 is populated in gridview and i do not see any combobox instead i see only columns from adapter2 2. I do not see the adapter1 filled at all???

    void fillData()
    {
    database = new OleDbConnection(connectionString);
    database.Open();
    OleDbDataAdapter adapter1 = new OleDbDataAdapter("select BillD.ProductName,BillD.ProductID,BillD.Saletype,BillD.InQty,BillD.SBtype,BillD.Dis1,BillD.Type,BillD.InPrice from BillDetails BillD", database);
    OleDbDataAdapter adapter2 = new OleDbDataAdapter("Select Products.ProdID,Products.ProductName,Packing.PackingName from Packing INNER JOIN Products ON Packing.PackingID=Products.Packing", database);

    {
    DataGridViewComboBoxColumn dgridcolumn = new DataGridViewComboBoxColumn();
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();
    DataTable packDT = new DataTable();
    adapter1.Fill(dt);
    dataGridView1.DataSource = dt;
    adapter2.Fill(packDT);
    ds.Tables.Add(packDT);
    dataGridView1.DataSource = ds;
    dataGridView1.DataMember = ds.Tables[0].TableName;
    dgridcolumn.DataSource = ds.Tables[0];
    dgridcolumn.ValueMember = ds.Tables[0].Columns[1].ColumnName.ToString();
    }
    }

    Thanks, Please help

    modified on Friday, March 13, 2009 4:51 AM

    C# database help question

  • Add combox in gridview - Getting OledbException
    H haroon1980

    sorry i am not getting exception as i fixed it bec of a pb in sql query...

    C# help database

  • Add combox in gridview - Getting OledbException
    H haroon1980

    Hi, I get Oledb Exception:"No value given for one or more required parameters." at line below adapter2.Fill(packDT); // error here on this line Basically i am trying to make a combobox in 2nd row of gridview.. Also one more thing i need to add to my above post..that i need to select some columns from one table and then in one of the column of the gridview i need to add combobox in gridview... OleDbDataAdapter adapter1 = new OleDbDataAdapter("select BillD.ProductName,BillD.ProductID,BillD.Saletype,BillD.InQty,BillD.SBtype,BillD.Dis1,BillD.Type,BillD.InPrice from BillDetails BillD", database); OleDbDataAdapter adapter2 = new OleDbDataAdapter("Select P.ProductName,P.ProductID,Packing.PackingName from Packing INNER JOIN Products ON Packing.PackingID=Products.Packing", database);

    void fillData()
    {
    database = new OleDbConnection(connectionS :( :confused:tring);
    database.Open();
    OleDbDataAdapter adapter1 = new OleDbDataAdapter("select BillD.ProductName,BillD.ProductID,BillD.Saletype,BillD.InQty,BillD.SBtype,BillD.Dis1,BillD.Type,BillD.InPrice from BillDetails BillD", database);
    OleDbDataAdapter adapter2 = new OleDbDataAdapter("Select P.ProductName,P.ProductID,Packing.PackingName from Packing INNER JOIN Products ON Packing.PackingID=Products.Packing", database);

            {
                DataGridViewComboBoxColumn dgridcolumn = new DataGridViewComboBoxColumn();
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataTable packDT = new DataTable();
                adapter1.Fill(dt);
                dataGridView1.DataSource = dt;
                adapter2.Fill(packDT); // error here on this line
                ds.Tables.Add(packDT);
                dataGridView1.DataSource = ds;
                dataGridView1.DataMember = ds.Tables\[0\].TableName;
                dgridcolumn.DataSource = ds.Tables\[0\];
                dgridcolumn.ValueMember = ds.Tables\[0\].Columns\[1\].ColumnName.ToString();
    
    
            }
    

    Thanks, please help

    C# help database

  • OledbException when trying to Insert values in two combobox
    H haroon1980

    I got the solution of how to tackle and did it by doing SQL query again to be bit corrected..and now no exception...

    private void Form1_Load(object sender, EventArgs e)
    {

            string sql ="SELECT distinct ProductName FROM Products";
            string sql2 = "SELECT DISTINCT Packing.PackingName FROM Packing INNER JOIN Products ON Packing.PackingID=Products.Packing";
            
    
    		DataSet ds=new DataSet();
            
            
    		try 
    		{
    			database = new OleDbConnection(connectionString);
                database.Open();
    		}
    		catch (Exception x)
    		{
    			MessageBox.Show(x.Message);
    		}
    		
            OleDbDataAdapter adp = new OleDbDataAdapter(sql, database);
            adp.Fill(ds, "ProductName");
    
            adp = new OleDbDataAdapter(sql2, database);
            adp.Fill(ds,"PackingName");
    						
    		foreach (DataRow dr in ds.Tables\[0\].Rows) 
    		{
    			comboBox3.Items.Add(dr\[0\].ToString()) ;
                                comboBox1.Items.Add(dr\[1\].ToString());
             		
    		}
    

    But now in combobox1 i get the same values as in combobox3? :confused: I think so pb in foreach loop? Any advise please...

    C# database help workspace

  • OledbException when trying to Insert values in two combobox
    H haroon1980

    Thanks Yusuf, But i have one different issue then just oledb exception... I have two tables Products=ProdId,ProdName,Price,Packing(Number as datatype) Packing=packingId,PackingName (Text as datatype) Now below code is in C# ..first check pls if "sql2" is correct query and then when i execute an application i get an error "Expression Mismatch" on line: adp.Fill(ds,"PackingName"); Thanks, regards,

    C# database help workspace

  • OledbException when trying to Insert values in two combobox
    H haroon1980

    Hi, Here is below code as i am trying to populate two combobox for different values but getting OledbException while running: I have two tables called Packing and Products Packing=id,name Products:id,prodname,price,packing [defined by number] I have setup relation between them in MSAccess which is done.. Product.Packing=Number Packing.PackingName=Text Code:

    private void Form1_Load(object sender, EventArgs e)
    {

            string sql ="SELECT distinct ProductName FROM Products";
            string sql2 = "SELECT  pac.PackingName FROM Products prod,Packing pac where prod.Packing=pac.PackingName ";
                        
                        DataSet ds=new DataSet();
            
                        try 
                        {
                                database = new OleDbConnection(connectionString);
                database.Open();
                        }
                        catch (Exception x)
                        {
                                MessageBox.Show(x.Message);
                        }
                        
                        OleDbDataAdapter adp=new OleDbDataAdapter(sql,database);
            adp = new OleDbDataAdapter(sql2,database);
            
                        adp.Fill(ds,"ProductName");
            adp.Fill(ds,"PackingName");
                                                        
                        foreach (DataRow dr in ds.Tables\[0\].Rows) 
                        {
                                comboBox3.Items.Add(dr\[0\].ToString()) ;
                comboBox1.Items.Add(dr\[1\].ToString());
                                        
                        }
            
    
            }
    

    Any help please...Thanks,

    C# database help workspace

  • Populating combobox with values from Table using C#
    H haroon1980

    thanks Yusuf, i just want to see the product names in this comboBox thats all..and which will come from Products Table... regards, :confused:

    C# database csharp question

  • Populating combobox with values from Table using C#
    H haroon1980

    Hi Jimmanuel, ...What else method or way u recommend instead of SelectedIndexChanged ? can u pls gimme example? ... I have 3 fields in that table so why it is inefficient? i have changed code and following is here: to include dr.close method..

    private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
    {
    try
    {

                database = new OleDbConnection(connectionString);
    
                // Create a command object and then a query which accepts a papameter
                System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("Select distinct ProductName from Products", database);
                database.Open();
                System.Data.OleDb.OleDbDataReader dr;
                dr = cmd.ExecuteReader();
    
                while (dr.Read())
                {
                    //comboBox3.Items.AddRange(new object\[\] { dr\[1\].ToString() });  //Change the index according to the values you want to populate in the combobox.
                    comboBox3.Items.AddRange(new Object\[\] { dr\[1\].ToString() });
                    
                }
                dr.Close();
            }
            catch (Exception ex)
            {
    
                MessageBox.Show(ex.Message);
                return;
            }
    

    }

    please help

    C# database csharp question

  • Populating combobox with values from Table using C#
    H haroon1980

    Hi, I have following function below but is not populating values from the table product?

    private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
    {
    try
    {

                database = new OleDbConnection(connectionString);
    
                // Create a command object and then a query which accepts a papameter
                System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("Select \* from Products", database);
                database.Open();
                System.Data.OleDb.OleDbDataReader dr;
                dr=cmd.ExecuteReader();
    
                while (dr.Read())
                {
                    //comboBox3.Items.AddRange(new object\[\] { dr\[1\].ToString() });  //Change the index according to the values you want to populate in the combobox.
                    comboBox3.Items.Add(dr\["ProductName"\]);
    
                }
            }
                catch (Exception ex)
            {
    
                MessageBox.Show(ex.Message);
                return;
            }
                
               
               }
    

    regards,

    C# database csharp question

  • Populating textbox and listbox values from MS Access tables
    H haroon1980

    Any help please...:confused:

    C# help tutorial question

  • Populating textbox and listbox values from MS Access tables
    H haroon1980

    Hi.. I have a form which is like following: Sup.Id: tbox1 S.Name:tbox6 ->When i select 1 it should populate the textbox6 with the proper name? how to do that? Prod_Name: listbox1...It should only show product name once not twice how to do that? Prod_Type: listbox2 -> How to view only product type e.g. F,H and T CostPrice: tbox4 -> It should calculate from product table? Prod.TradePrice:tbox5 Now as you see i have two tables Suppliers and Products.. In products table i have e.g. p.name=prodA p.type=F p.Price=100 p.name=prodA p.Type=H p.Price=50 Suppliers Table: S.id=1 S.Name=InStock I will be very thankful to you pls help out...

    C# help tutorial question

  • Populating Data from MS Access
    H haroon1980

    THANKS Eddy

    C# css help

  • Populating Data from MS Access
    H haroon1980

    Thanks..but I am not very expert and quick on wat y mentioned...Can you pls be more in steps if possible? Regards,

    C# css help

  • Populating Data from MS Access
    H haroon1980

    Hi, I have a datagrid and I want to populate it from the tables in MS Access. Also I want to get the combination of different columns from the 3 Tables and populate them by providing my own column names in DATA GRID. I will be very thankful to you in this regards, I am in need of it sooner please help... :( Haroon

    C# css help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups