当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Saving Insertions into a database

问题描述:

I am updating a database using C# & SQL. When I insert a value into the table it exists in the table until I close the connection. How do I save the values that I inserted? Here is the code that I am using:

 conn = new System.Data.SqlClient.SqlConnection();

conn.ConnectionString = "Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Unmapped.mdf;Integrated Security=True;User Instance=True";

string sql = "INSERT into unmappedTeamsTable values ('Value1', 'Value2', 'PW')";

SqlCommand insertCommand = new SqlCommand(sql, conn);

conn.Open();

insertCommand.ExecuteNonQuery();

conn.Close();

Thanks

网友答案:

Set a brakepoint and see if your query is running or not.

I think your code is not executing properly.

分享给朋友:
您可能感兴趣的文章:
随机阅读: