0

Can anyone tell my why my local .sdf isn't populating data with the following routine:

internal static void InsertLocalNotify(string _em, string _phone, int _emon, int _phoneon)
{
    using (SqlCeConnection _con = new SqlCeConnection(Properties.Settings.Default.DomainsToTestConnectionString))
    {
        using (SqlCeCommand _cmd = new SqlCeCommand())
        {
                _cmd.Connection = _con;
                _cmd.CommandType = System.Data.CommandType.Text;
                _cmd.CommandText = "Insert Into ToNotify (NotifySendEmail, NotifySendText, NotifyEmailAddress, NotifyPhoneNumber, LastUpdated) Values (@NE, @NP, @EM, @PH, @LU)";
                _cmd.Connection.Open();
                _cmd.Parameters.AddWithValue("@NE", _emon);
                _cmd.Parameters.AddWithValue("@NP", _phoneon);
                _cmd.Parameters.AddWithValue("@EM", _em);
                _cmd.Parameters.AddWithValue("@PH", _phone);
                _cmd.Parameters.AddWithValue("@LU", DateTime.Now);
                _cmd.Prepare();
                _cmd.ExecuteNonQuery();
                _cmd.Parameters.Clear();
        }
    }
}

Table structure is:

NotifySendEmail int
NotifySendText int
NotifyEmailAddress nvarchar(500)
NotifyPhoneNumber nvarchar(500)
LastUpdated datetime

I've verified via stepping through the code, that all data passed in is correct.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kevin
  • 2,684
  • 6
  • 35
  • 64
  • p.s. I have even tried it non-parameterized and still no data gets inserted. No errors are thrown either – Kevin Sep 30 '14 at 16:59
  • 2
    It is a Classic - you are probably using |DataDirectory| in your connection string, and has the database file as project content, so you should look in bin/debug for a copy of the database file with data in it – ErikEJ Sep 30 '14 at 17:13
  • 1
    Consult [this answer](http://stackoverflow.com/a/13313075/22437). – Dour High Arch Sep 30 '14 at 17:32
  • thanks @ErikEJ I was able to open the one in bin/Debug and verify that it is indeed getting inserted. :) If you change your comment to an answer, I'll mark it – Kevin Sep 30 '14 at 18:44

1 Answers1

1

It is a Classic - you are probably using |DataDirectory| in your connection string, and has the database file as project content, so you should look in bin/debug for a copy of the database file with data in it

ErikEJ
  • 40,951
  • 5
  • 75
  • 115