1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Populating one Textbox from another textbox

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

  1. haroonshah1980

    haroonshah1980 New Member

    Joined:
    Mar 4, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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