I am having a small issue with SqlServerCe. When using the below sqlString to perform a ExecuteNonQuery(); command I get the error below.
string sqlString = "INSERT INTO Images (UID, Name) " +
"VALUES ((SELECT ID FROM Contributors WHERE ID = @UID), @Name);";
gives this error:
There was an error parsing the query. [ Token line number = 1,Token line offset = 41,Token in error = SELECT ]
Any suggestions?
Method
public static void InsertImage(Contributor contObj, string ImageName)
{
string sqlString = "INSERT INTO Images (UID, Name) " +
"VALUES ((SELECT ID FROM [Contributors] WHERE ID = @UID), @Name);";
using (SqlCeConnection sqlConnection =
new SqlCeConnection(WebConfigurationManager.ConnectionStrings["DefaultSQL"].ConnectionString))
{
SqlCeCommand sqlCommand = new SqlCeCommand(sqlString, sqlConnection);
sqlCommand.Parameters.AddWithValue("@UID", contObj.ID);
sqlCommand.Parameters.AddWithValue("@Name", ImageName);
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
sqlConnection.Close();
}
}