Hi,
Please any one explain me how to create a wcf service for the stored procedures. I have created a stored procedures namely Location and PopSublocation. For getting the Locations in the location dropdown list I have written the code like...
protected void LocationBind()
{
SqlConnection conn = new SqlConnection(connstr);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Location";
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
ddlLocation.DataSource = reader;
ddlLocation.DataTextField = "Location";
ddlLocation.DataValueField = "LocationID";
ddlLocation.DataBind();
ddlLocation.Items.Insert(0, new ListItem("Select", "-1"));
conn.Close();
reader.Close();
}
Then for populating the sublocation in another drop-down list i have created one more stored procedure(PopSublocation).It will take locationID as input according to the particular locationID it is going to populate the appropriate subLocation. The below code i have written to populate the Sublocation list in the dropdown.
protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(connstr);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "PopSublocation";
cmd.Parameters.AddWithValue("@location", Convert.ToInt32(ddlLocation.SelectedValue));
ddlSublocation.Items.Insert(0, new ListItem("Select", "-1"));
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddlSublocation.DataSource = ds.Tables[0];
ddlSublocation.DataTextField = "Sublocation";
ddlSublocation.DataValueField = "Sublocation";
ddlSublocation.DataBind();
}
Now i need to create a wcf service for both stored procedure and call them in the program. Please help me out for this, i am very new for this concept. Sorry for the inconvenience for any errors or not understanding.