CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    18

    retrieve a Column in C# from sql

    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

  2. #2
    Join Date
    Apr 2010
    Posts
    18

    Re: retrieve a Column in C# from sql

    thanks you all guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured