I have a SQL Server table with two columns Keyword
and Emotion
.
I want to search a word (which is specified in column Keyword
) inside a string which contains a sentence.. for eg:- How are you
I want to execute two queries:
I want to search if the string contains "how" (
how
is specified inKeyword
column)..If the string contains
how
, I want to display the corresponding value stored in theEmotion
column of the table
This is my sample code (which can be completely wrong :p):-
public partial class message : System.Web.UI.Page
{
string constring = ConfigurationManager.ConnectionStrings["AnonymiousSocialNetworkConnectionString"].ToString();
protected void btnsend_Click(object sender, ImageClickEventArgs e)
{
SqlConnection con = new SqlConnection(constring);
string value = txtmsg.Text;
con.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select emotion from messageanalysis where keyword CONTAINS'",con);
myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
lblStatus.Text = myReader["emotion"].ToString();// **this label should Display corresponding value stored in Emotion(column)**//
}
}
}