Inserting NULL values into mdf table in Windows Forms
<p>I cannot figure out what I am doing wrong here, in the debugger when I set breakpoints the strings all have string values in them, but when it comes time to insert them into the table, nothing gets put in.</p>

<p>the table is defined as follows </p>

<pre><code>CREATE TABLE [dbo].[tblMissEvents] (
[EventID]          INT            IDENTITY (1, 1) NOT NULL,
[EventTime]        NVARCHAR (MAX) NULL,
[MIS_Event_Action] VARCHAR (50)   NULL,
[Bogey_Type]       VARCHAR (50)   NULL,
PRIMARY KEY CLUSTERED ([EventID] ASC)
</code></pre>

<p>);</p>

<p>my code:</p>

<pre><code>        string date = DateTime.Now.ToString();
        string MISaction = text1.Text;
        string BogeyType = text2.Text;

        try
        {
            con = new SqlConnection();
            con.ConnectionString =
                @"data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\MissileEvents.mdf;integrated security=True;MultipleActiveResultSets=True;Connect Timeout=30";
            con.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText =
                "INSERT into tblMissEvents (EventTime, MIS_Event_Action, Bogey_Type) Values (@date, @MISaction, @BogeyType)";  
            cmd.Parameters.AddWithValue("@date", date);
            cmd.Parameters.AddWithValue("@MISaction", MISaction);
            cmd.Parameters.AddWithValue("@BogeyType", BogeyType);
            cmd.Connection = con;
            cmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        con.Close();
</code></pre>

<p>Any thoughts?? I don't get an exception, just no entry into my table.</p>

<p>edit for Arshad:</p>

<pre><code>        con = new SqlConnection();
        con.ConnectionString =
            @"data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\MissileEvents.mdf;integrated security=True;MultipleActiveResultSets=True;Connect Timeout=30";
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText =
            "INSERT into tblMissEvents (MIS_Event_Action, Bogey_Type) Values (@date, @MISaction, @BogeyType)";  
        cmd.Parameters.AddWithValue("@date", date);
        cmd.Parameters.AddWithValue("@MISaction", MISaction);
        cmd.Parameters.AddWithValue("@BogeyType", BogeyType);
        cmd.Connection = con;
        cmd.ExecuteNonQuery();
</code></pre>

<p>UPDATE:: The code was fine, it was making a copy of the DB in my bin\Debug directory and thats where all the data was going. Probably something with my connection string setup. Thanks all!</p>
