I have already figured it out.So for all people that wants a solution for the same issue.This is what i did :
I added a stored procedure to the database and here it is :
ALTER PROCEDURE dbo.StoredProcedure1
@Inventory_Title nvarchar(500)
AS
INSERT INTO Inventory
(Inventory_Title)
VALUES (@Inventory_Title)
Select SCOPE_IDENTITY()
RETURN
Then i added a query into the table adapter,that has the stored procuder as its source.Then i called the method from the code using c# and this is the code :
DataSet1TableAdapters.InventoryTableAdapter da=new DataSet1TableAdapters.InventoryTableAdapter();
int id = Convert.ToInt32( da.InsertWithReturn("Inv1"));
And by this way i got the last inserted id.