I have a web page that I want to insert keywords into a database when they do a search. The problem is when a search is done, the keyword is inserted. When another search is done both the old keyword and a new keyword are inserted. I have the following stored procedure and code ...
CREATE PROCEDURE dbo.sp_addKeywords
@keywords varchar(100)
AS
Insert into searchRequests (keywords) values (@keywords)
RETURN
GO
*************************
SqlConnection cn2 = new SqlConnection(Configuration.DBConnectionString);
SqlCommand cmd2 = new SqlCommand("sp_addKeywords", cn2);
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.Add("@keywords", SqlDbType.VarChar, 100).Value = keywords;
cn2.Open();
SqlDataReader result2 = cmd2.ExecuteReader(CommandBehavior.CloseConnection);
result2.Close();
cn2.Close();
I have found lots of discussions about this, just no sure answer.
Thanks,
TJ
CREATE PROCEDURE dbo.sp_addKeywords
@keywords varchar(100)
AS
Insert into searchRequests (keywords) values (@keywords)
RETURN
GO
*************************
SqlConnection cn2 = new SqlConnection(Configuration.DBConnectionString);
SqlCommand cmd2 = new SqlCommand("sp_addKeywords", cn2);
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.Add("@keywords", SqlDbType.VarChar, 100).Value = keywords;
cn2.Open();
SqlDataReader result2 = cmd2.ExecuteReader(CommandBehavior.CloseConnection);
result2.Close();
cn2.Close();
I have found lots of discussions about this, just no sure answer.
Thanks,
TJ