I'm trying to write to a data base, I have been working of the following site. In particular the LoadARow
function.
I have been getting the runtime error
"System.IndexOutOfRangeException: A SqlCeParameter with ParameterName 'Value' is not contained by this SqlCeParamaterCollection.
The error references the line "command.Parameters["@Value"].Value = num;". The database I'm using has a Value column set as the key, and a text column.
using (SqlCeConnection connect = new SqlCeConnection("Data Source=C:\\Users\\mike\\Documents\\database.sdf"))
{
connect.Open();
string text = "test";
int num = 0;
using (SqlCeCommand command = new SqlCeCommand("insert into Data Table values (@Value, @Text)", connect))
{
command.Parameters.Add("@Text", SqlDbType.NVarChar);
command.Parameters["@Value"].Value = num;
command.Parameters.AddWithValue("@Text", text);
command.ExecuteNonQuery();
}
}