Reputation: 380
I am querying with this code
SqlCommand Update = new SqlCommand("UPDATE TermsTable SET Doc_ID += @Doc, Freq += @Frq ,Postion += @Pos WHERE Term=@Trm ", GetConnection());
Update.Parameters.Add(@"Doc", SqlDbType.NVarChar).Value = (";" + ID.ToString()).ToString();
Update.Parameters.Add(@"Frq", SqlDbType.NVarChar).Value = (";" + PureContent.CountWordinThext(word, PureContent.GetContentPure)).ToString();
Update.Parameters.Add(@"Pos", SqlDbType.NVarChar).Value =( ";" + PureContent.GetPostionWithinStrin(PureContent.GetContentPure, word)).ToString();
Update.Parameters.Add(@"Trm", SqlDbType.NVarChar).Value = (";" + word.ToLower()).ToString();
Update.ExecuteNonQuery();
Update.Parameters.Clear();
To update table with adding new value to it's original value, it worked fine on my SQL machine - otherwise my machine it executed but with no update in my table.
Upvotes: 0
Views: 74
Reputation: 820
Change:
Update.Parameters.Add(@"Trm", SqlDbType.NVarChar).Value = (";" + word.ToLower()).ToString();
To
Update.Parameters.Add(@"Trm", SqlDbType.NVarChar).Value = word;
Remove the semicolon to search for only the word
"term" you want and remove the ToLower
as it is case sensitive.
EDIT:
By the way all these ToString()
are redundant; for example you could change:
Update.Parameters.Add(@"Doc", SqlDbType.NVarChar).Value = (";" + ID.ToString()).ToString();
to
Update.Parameters.Add(@"Doc", SqlDbType.NVarChar).Value = ";" + ID;
Upvotes: 1