Hello, I can't seem to find why this function doesn't insert records into the database. :( I get no error messages or whatsoever, just nothing in the database.
EDIT: this is how my query looks now .. still nothing ..
connection.Open();
XmlNodeList nodeItem = rssDoc.SelectNodes("/edno23/posts/post");
foreach (XmlNode xn in nodeItem)
{
cmd.Parameters.Clear();
msgText = xn["message"].InnerText;
C = xn["user_from"].InnerText;
avatar = xn["user_from_avatar"].InnerText;
string endhash = GetMd5Sum(msgText.ToString());
cmd.Parameters.Add("@endhash",endhash);
cmd.CommandText = "Select * FROM posts Where hash=@endhash";
SqlCeDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string msgs = reader["hash"].ToString();
if (msgs != endhash || msgs == null)
{
sql = "INSERT INTO posts([user],msg,avatar,[date],hash) VALUES(@username,@messige,@userpic,@thedate,@hash)";
cmd.CommandText = sql;
cmd.Parameters.Add("@username", C);
cmd.Parameters.Add("@messige", msgText.ToString());
cmd.Parameters.Add("@userpic", avatar.ToString());
cmd.Parameters.Add("@thedate", dt);
cmd.Parameters.Add("@hash", endhash);
cmd.ExecuteNonQuery();// executes query
adapter.Update(data);// saves the changes
}
}
reader.Close();
}
connection.Close();