Ali Ashiq

Ali Ashiq

  • NA
  • 61
  • 31.9k

How to get records from different tables using webservices

Feb 1 2014 12:04 PM
Here is my Database diagram and my scenario is that When a user enter number of person and amount, amount/person
let suppose 4/1000=250 and now 250 is , match in Product_Price Field in RstProductDetails, and select only Restaurant where 250 is matched. Next when a user select Restaurant e.g KFC and then KFC Products details is show.
Here is my [WebMethod]

 [WebMethod]
    public DataSet Restaurant(string amount, string persons)
    {
        //        DataSet result = Amount / personHash;
         decimal price = amount \ persons ;
        DataSet result = null;
        const string SQL_COMMAND_TEXT = "SELECT Rst_Name FROM RstProductDetails WHERE Product_Price WHERE Product_rice< = @price";
        using (SqlConnection connection = Class1.GetConnection())
        {
            connection.Open();
            using (SqlCommand command = new SqlCommand(SQL_COMMAND_TEXT, connection))
            {
                command.Parameters.Add("@Rst_Name", SqlDbType.NVarChar);
                command.Parameters.Add("@PersonHash", SqlDbType.NVarChar);
                command.Parameters.Add("@price", SqlDbType.Decimal);
                command.Parameters["@Rst_Name"].Value = amount;
                command.Parameters["@persons"].Value = persons;
                command.Parameters["@price"].Value = price;
                using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
                {
                    result = new DataSet();
                    dataAdapter.Fill(result);
                }
            }
        }

        return result;
    }


Here is my databse relation diagram

Attachment: diagram1.zip