Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SQLCE C# Not Selecting New Records

SQLCE C# Not Selecting New Records

Scheduled Pinned Locked Moved C#
csharpdatabasevisual-studio
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hobbsieoz
    wrote on last edited by
    #1

    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
                            {
                                
                            }
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups