OleDb parameters are recognized by position, not by their name. So at first sight, you seem to add them in the right order. But the problem with subquerys is, that they will be processed first. So the correct order of the parameters is: email, msg, uid
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@msg", "You have received a friend request from " + returnName(uid));
cmd.Parameters.AddWithValue("@uid", uid);
And yes, ExecuteNonQuery is the right method
By the way, is ConnectionManager.getConnection() returning an open connection? If not, you need to open the connection before calling ExecuteNonQuery
hans_v
All-Star
35986 Points
6550 Posts
Re: How to use nested queries
Jan 17, 2012 08:36 AM|LINK
OleDb parameters are recognized by position, not by their name. So at first sight, you seem to add them in the right order. But the problem with subquerys is, that they will be processed first. So the correct order of the parameters is: email, msg, uid
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@msg", "You have received a friend request from " + returnName(uid));
cmd.Parameters.AddWithValue("@uid", uid);
And yes, ExecuteNonQuery is the right method
By the way, is ConnectionManager.getConnection() returning an open connection? If not, you need to open the connection before calling ExecuteNonQuery