|
I am writing a popular search`
The idea is to use a SQL table to store search words that the user can find with a result greater than 1.
But one problem is that if the keyword already exists in the database, then it will not be repeated?
My code is written like this:
int newcount = 1;
try
{
SqlCommand upcount = new SqlCommand ("update aspnet_HotSearch set Count = Count + 1 Where KeyWord = '" + key + "'", mysqlSqlConnection);
upcount.ExecuteNonQuery ();
}
catch
{
SqlCommand intoKey = new SqlCommand ("insert into aspnet_Hot (Key, Count) value ('" + key + "', '" + newcount + "')", mysqlSqlConnection);
intoKey.ExecuteNonQuery ();
}
But it's useless, so please tell me how to write
By the way, are there any better ideas for popular searches? |
|