-
Feb 25th, 2018, 02:50 PM
#1
Thread Starter
PowerPoster
Can't add SQL Server Compact 4.0 db to my solution?
I'm running Windows 10 on my laptop and I have successfully installed MS SQL Server Compact 4.0. However, I'm not sure how to incorporate a Compact version of the database into my solution. I'm using the VS 2015 Community edition.
-
Feb 25th, 2018, 05:26 PM
#2
Re: Can't add SQL Server Compact 4.0 db to my solution?
As Microsoft are no longer developing SQL Server CE, they removed the dedicated functionality from VS. You used to be able to select File-based Database (or similar) from the Add New Item dialogue to create and add a new SDF file to your project. I think that VS 2013 was the last version to include that though. I've never tried, but I would assume that you could still create an SDF file externally and add it as an Existing Item, just as you do an Access MDB or ACCDB file. You'd also have to add the appropriate reference for the SQL Server CE ADO.NET provider, which is probably installed as part of SQL Server CE itself.
-
Feb 25th, 2018, 07:00 PM
#3
Thread Starter
PowerPoster
Re: Can't add SQL Server Compact 4.0 db to my solution?
Thanks jmc...my whole point to trying to use SQL Server CE was to create an app without needing to install a full-blown version of SQL Server. Guess I need to continue researching the best way to store data securely without have to install a commercial grade DBMS.
Thanks,
-
Feb 25th, 2018, 07:33 PM
#4
Re: Can't add SQL Server Compact 4.0 db to my solution?
You have two choices.... SQLite, or SQL CE... there's nothing stopping you from using SQL CE if that's what you want to use. You'll just need to copy the appropriate DLLs for CE (which I think amounts to something like 7 assemblies) and make sure they are in your app folder and you have a reference to the main assembly. As for the database itself, it's just a file at that point, so... just add it to your project.
-tg
-
Feb 25th, 2018, 07:33 PM
#5
Re: Can't add SQL Server Compact 4.0 db to my solution?
Microsoft's own recommendation for a file-based database these days is SQLite. I've not heard anything official but I think that they probably discontinued SQL Server CE because it didn't really offer anything that the already-popular SQLite didn't.
-
Feb 25th, 2018, 09:31 PM
#6
Thread Starter
PowerPoster
Re: Can't add SQL Server Compact 4.0 db to my solution?
Looks like I'll be taking a look at SQLite then...thanks guys!
-
Feb 25th, 2018, 10:22 PM
#7
Re: Can't add SQL Server Compact 4.0 db to my solution?
Don't mean to hijack this thread but I thought SQLExpress came pre installed on all Windows machines sense Win7. Has something changed?
-
Feb 25th, 2018, 11:14 PM
#8
Re: Can't add SQL Server Compact 4.0 db to my solution?
Originally Posted by wes4dbt
Don't mean to hijack this thread but I thought SQLExpress came pre installed on all Windows machines sense Win7. Has something changed?
SQL Server Express and SQL Server Compact Edition are two very different things. The former is an edition of SQL Server with fewer features, so it is still service-based. SQL Server CE is SQL Server in name only. It is completely different and is file-based, with the database engine being a small number of DLLs that can deployed with an app if desired.
That said, SQL Server Express is not installed as part of Windows. It still gets installed with VS.
-
Feb 26th, 2018, 01:56 AM
#9
Re: Can't add SQL Server Compact 4.0 db to my solution?
Thanks for clearing that up.
-
Feb 26th, 2018, 10:40 AM
#10
Thread Starter
PowerPoster
Re: Can't add SQL Server Compact 4.0 db to my solution?
I do have a question regarding SQLite. Where is the .sdf file stored at. I only ask because I just want to be able to use a editor like DB Browser to verify the data contents. I don't see the file anywhere within my solution.
-
Feb 26th, 2018, 01:41 PM
#11
Re: Can't add SQL Server Compact 4.0 db to my solution?
I've only used SQLite in one small project but it didn't create an .sdf file, it created a .db file.
-
Feb 26th, 2018, 01:49 PM
#12
Thread Starter
PowerPoster
Re: Can't add SQL Server Compact 4.0 db to my solution?
I didn't even see that. I figured it would be somewhere in the file structure of my solution but I checked everywhere and didn't see one. The file name that I have defined in my app is called "Banker.sqlite".
-
Feb 26th, 2018, 08:27 PM
#13
Re: Can't add SQL Server Compact 4.0 db to my solution?
I've never used SQLite but, from what I've read, it's my understanding that there are no VS tools to create a database. You have to either do it externally and then add the file to your project as an existing item, or else create the file and build the schema in code. If you have DB Browser then I believe that it should be able to create the database externally for you.
Note that SDF files are specifically SQL Server CE. It is not a standard used by other vendors.
-
Feb 26th, 2018, 08:35 PM
#14
Thread Starter
PowerPoster
Re: Can't add SQL Server Compact 4.0 db to my solution?
I did download DB Browser and am going to try what you suggested. But you are correct jmc, there are no tools in VS to create the database as I have already tried that.
-
Feb 26th, 2018, 08:44 PM
#15
Re: Can't add SQL Server Compact 4.0 db to my solution?
This is for C# but all the principles are the same in VB:
http://blog.tigrangasparian.com/2012...in-c-part-one/
That shows how to create and build the database in code, if you haven't already created the file externally.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|