SQL Server Compact Database How do I view contents?
I have a very simple application in c# it has a Microsoft SQL Server Compact 3.5 (.NET Framework Data Provider for Microsoft SQL Server Compact 3.5) data connection / database.
What I would like to do is be able to view the contents of the database while the program is running.
If 开发者_运维百科i add the dataset to the GUI i can delete / add contents however if under Sever explorer issue a NEW QUERY and ask it to list all the contents if comes back blank.
It is either connecting to the wrong database, not saving the contents or something else.
Any ideas ?
I should add that I want to make a small application with its own internal database for logging information. The application I could then send to my sister, she can install and that's that... no more hassle
If you want a little more functionality and flexibility than what Visual Studio provides, one product you can use is SQL Server Management Studio Express. This is the free version, but still very fully featured. You can do everything in it, including design the tables and run arbitrary sql statements - and it can be used to connect to any SQL Server edition.
To use it on your SQL Compact database, just fire it up, in the connection dialog you select SQL Server Compact from the Server Type dropdown, browse to your sdf file in the Database File field, and type in any password required.
I'm not sure what version of Visual Studio you have. But this is a problem I've encountered a number of times.
When you build the application it copies the database file into the appropriate bin directory, so your running app will be looking at that database by default. The server explorer will be connecting to the original copy, which has no data in it.
If you want to be able to see the contents of the database used by the running app you could try explicitly setting you connection string in server explorer to look at the database in the bin folder, or copy the one from the bin folder to where your server explorer is looking.
精彩评论