I use SqlConnection and SqlCommand classes in my project with Dapper ORM but I ve got a strange problem. When I use SqlCommand for inserting a row in a db table it always work correct and when I select updated data form tables everything is fine but after close the application changes I made isn t commited like data have been saved in some cache. For example I created a simple table with only two columns (UserId (PK), and UserName (Unique)) and even in that case changes aren t saved. I m using the following code for inserting a row:
using (SqlConnection c = new SqlConnection(Settings.Default.UsersConnectionString))
{
c.Open();
using (SqlCommand d = new SqlCommand())
{
d.CommandText = "INSERT INTO Users (UserName) VALUES ( SomeName )";
d.CommandType = System.Data.CommandType.Text;
d.Connection = c;
int t = d.ExecuteNonQuery();
}
c.Close();
}