0

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

Edited by __avd: Added [code] tags.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by khadakbist
0

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()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.