I am developing a C# Windows Application which inserts data into a SQLCE database. It inserts fine, that works great! However, if i want to select the new record from the database, it comes back as a blank result. I can search for previous records before i opened the applications. Its as though the database opens a cached copy, and you can only insert into it. Here is my current code. Has anybody else had similar issues.
private void button2\_Click(object sender, EventArgs e)
{
if (txtAddRegistration.Text != "")
{
if (comboAircraft.Text != "")
{
if (comboAirline.Text != "")
{
if (comboLocation.Text != "")
{
int picyesorno;
string picloc;
if (txtAddPicLoc.Text == "")
{
picyesorno = 0;
picloc = "";
}
else
{
picyesorno = 1;
picloc = txtAddPicLoc.Text;
}
string InsertRegCommand = "INSERT INTO SPOTTINGLOG (registration, aircraft, airline, location, date, pictured, picloc, comments) values('" + txtAddRegistration.Text + "','" + comboAircraft.Text + "','" + comboAirline.Text + "','" + comboLocation.Text + "'," + dateTimePicker1.Value.ToShortDateString() + "," + picyesorno + ",'" + picloc + "','" + txtAddComments.Text + "')";
string database = @"D:\\Daniel\\Documents\\Visual Studio 2008\\Projects\\AviationSpottingLog\\AviationSpottingLog\\SpotData.sdf";
try
{
SqlCeConnection conn = new SqlCeConnection("Data Source=" + database);
conn.Open();
SqlCeCommand command = new SqlCeCommand();
command.Connection = conn;
command.CommandText = InsertRegCommand;
command.ExecuteNonQuery();
conn.Close();
}
catch
{
}