Results 1 to 15 of 15

Thread: Can't add SQL Server Compact 4.0 db to my solution?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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,
    Blake

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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!
    Blake

  7. #7
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    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?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Can't add SQL Server Compact 4.0 db to my solution?

    Quote Originally Posted by wes4dbt View Post
    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.

  9. #9
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: Can't add SQL Server Compact 4.0 db to my solution?

    Thanks for clearing that up.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  11. #11
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    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.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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".
    Blake

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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
  •  



Click Here to Expand Forum to Full Width