I have develop a function to add textbox value into data base my function work perfectly .now I am using that table primary key into another table where it declare as a foreign key now i required to return my Id as a output parameter in table1 means( set scope identity) so that I used this Id into another table as a foreign key please help me how I used this scope identity into a web method
function Insertdata()
{
var name = $('#txtfname').val();
$.ajax({
type: 'POST',
url: "Insert.aspx/DataInsertion",
contentType: "application/json; charset=utf-8",
data: '{name:"' + name + '", Id:"' + output + '"}',
async: false,
success: function (response) {
alert(" Saving the Data.!");
},
error: function () {
alert("Some Error occured While Saving the Data.!");
}
});
};
Web method
[WebMethod]
public static string DataInsertion(string name Id output)
{
using (var db = new MyEntities())///////this is edmx name
{
db.Insertion(
Name=name,
Id=Output
);
}
return " Data Successfully Saved";
}
I read a lot of article but I have no idea to use it.
Please help me