Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Populating one Textbox from another textbox (http://www.go4expert.com/forums/populating-textbox-textbox-t16428/)

haroonshah1980 4Mar2009 18:16

Populating one Textbox from another textbox
 
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,


All times are GMT +5.5. The time now is 18:43.