Retrieve Column in C# from SQL

Discussion in 'C#' started by m0j1, Jul 18, 2010.

  1. m0j1

    m0j1 New Member

    Joined:
    Jul 18, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi , I have a form name "Sale" and it has a comboBox wich shows the products . products list is in a table in sql names Products . the Products table has three columns : ProductName , count , Price .
    I want to retrieve the Price in C# when I click a certain button . I have wrote the code as below but I don't have any idea how to complete it .

    SqlDataAdapter objAdapter = new SqlDataAdapter();
    objAdapter.SelectCommand = new SqlCommand();
    objAdapter.SelectCommand.Connection = objconnection;
    objAdapter.SelectCommand.CommandText = "select Price from Products where ProductName=@ProductName";
    objAdapter.SelectCommand.Parameters.AddWithValue("@ProductName", cmbBox1.Text);

    anyone knows how should I do that?
    thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice