Hi my problem is that so I can't add new data to database.
I wrote procedure in mssql 2008 and now i don't now how coneecting this with asp.net

Create procedure [dbo].[addData]

@name nvarchar(50),
@telephone int,
@place nvarchar(50),
@street nvarchar(50)


AS
Declare
@person_id int,
@place_id int
BEGIN
if not exists(select Person.name,Person.telephone from Person where telephone=@telephone)
begin
print'exist in database'
return
select @Person_id=Person_id  from Person where telephone=@telephone

end
IF EXISTS (SELECT Place.place,Place.street FROM Place )
SELECT @place_id=place_id FROM Place

insert into Person(person_id,name,telephone)
values(@person_id,@name,@telephone)       
insert into Place(place,street)
values(@place,@street)
end

as you have already written the stored procedure , you can call the same via ado.net as shown in the below code. You can see the adddata stored procedure in the below code

SqlConnection conn = new SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
conn.Open();
SqlCommand cmd  = new SqlCommand("addData", conn);
cmd.CommandType = CommandType.StoredProcedure;
rdr = cmd.ExecuteNonQuery()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.