1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Populating one Textbox from another textbox

Discussion in 'C#' started by haroonshah1980, Mar 4, 2009.

  1. haroonshah1980

    haroonshah1980 New Member

    Hi,

    I have a problem as I want to populate S.Name populated when i select the SupplierID

    I am using MS access Database And i have in total 3 tables...
    In products table i have e.g.

    p.name=prodA
    prod_type=F
    p.Price=100

    p.name=prodA
    p.Type=H
    p.Price=50

    ....
    ...

    Suppliers Table:
    S.id=1
    S.Name=InStock

    S.id=2
    S.Name=EBM

    And taking data from these above two tables i am trying to insert in Supplier Windows Form (Table: Supplier Detail)

    SupId
    S.Name
    product_Name
    product_type
    Product_Price
    P.Qty
    Discount
    ProductPriceAfterdiscount (Should calculate based on what discount applied on Product_price)


    ...And here is the code
    Code:
    public Form1()
            {
    
                InitializeComponent();
                // iniciate DB connection
                string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\EnglishBisuit\\My.mdb";
                try
                {
    
                    database = new OleDbConnection(connectionString);
                    database.Open();     
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
       
    
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                
                String q = "Select SupplierName from Suppliers where Supplier id=" + sender;
                textBox2.Text = textBox2.Text.ToString(q); //something wrong here
            }
    
    Hope i am enough clear... Please help out

    Thanks,
    Regards,
     

Share This Page