Why can't I insert a record into the SQL Compact 3.5 database?

I just made a very simple test application using the documentation from MSDN. All I want to do is insert a record into my table, which is in the SQL Server Compact database in the VS 2010 application.

But when I run it, it acts as if it is running fine (no errors), but the record is never inserted into my SQL Compact 3.5 database when I go to view the table data from Server Explorer.

My code is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;

namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {
        SqlCeConnection conn = null;

        try
        {
            conn = new SqlCeConnection("Data Source = test.sdf; Password ='pass'");
            conn.Open();
            SqlCeCommand cmd = conn.CreateCommand();
            cmd.CommandText = "INSERT INTO TEST ([test]) Values('NWIND')";

            cmd.ExecuteNonQuery();
        }
        finally
        {
            conn.Close();
        }

    }
}

}

I have a database called test.sdf. It contains the table "test" with 1 column "test".

My test application is available at: http://dl.dropbox.com/u/3051071/ConsoleApplication1.zip

test.sdf .

, . , , null .

-, , , ?

.

+3
2

.sdf SSMS? - .sdf bin\Debug - .

+8

| DataDirectory | confy, db Bin\Debug Folder.... : -)

Bin\Debug: -/ , :-(, , thankx fellas

...

0

Source: https://habr.com/ru/post/1768821/


All Articles