How to update cell value in dB table using SQL Server CE and C # (Visual Studio 2010)

I am writing a small college app, a video rental app. I have no problem reading from the database, but I cannot update the data in the tables.

In particular, I want to update the camera by showing the amount of film in the warehouse after someone rents the film.

So far I have tried to do this:

string updateDVDs = "UPDATE Products SET dvd_quantity = " + product.Quantity + " WHERE title = '"+ product.Name +"';";
cmdUpdateDVDs = new SqlCeCommand(updateDVDs, dBConnection);
dBConnection.Open();
cmdUpdateDVDs.ExecuteNonQuery();
dBConnection.Close();

I am not getting any errors, but the cell is not updating in the table. Any help would be greatly appreciated, please let me know if you need further information.

UPDATE: Well, I have some interesting developments, I updated the code:

string updateDVDs = "UPDATE Products SET dvd_quantity = " + product.Quantity + " WHERE title = '" + product.Name + "'";
dBConnection = new SqlCeConnection(connectionString);
cmdUpdateDVDs = new SqlCeCommand(updateDVDs, dBConnection);
cmdUpdateDVDs.Connection.Open();
int rows = cmdUpdateDVDs.ExecuteNonQuery();
dBConnection.Close();

, , MSDN, , , , . , "Die Hard", , :

Database updated

, , . "Die Hard" , , , ! DVD- 0, : DVD quantity successfully updated!

, Product Visual Studio, : In Visual Studio the table hasn't updated

, Visual Studio, DVD reset , .

- ? , . Visual Studio, , , , , , .

0
2

, , , " , bin", . , c:\Users\Me\Visual Studio 2010\Projects\MyProject\bin\debug\HKRMoviesDB.sdf? , VS2010 - , .

ADO.NET , AppDomain. , Data Source=|DataDirectory|\HKRMoviesDB.sdf VS, DataDirectory bin , VS DLL. MSI, DataDirectory , . .

, DataDirectory , ; , , , Environment.SpecialFolder.ApplicationData - , .

, . , , , , , , , . , " " . ", ", , , , , , ; , , . , , DataDirectory .

+2

:

" , , , , , - /bin/debug/. , Visual Studio, , ".

, bin.

0

All Articles