3

I am currently working with a client who uses SQL Server CE databases. I would like to open and view the database. I read that Visual Studio 2017 has the ability to open these database files (.sdf).

I have been tinkering around for a few hours on VS and I can't seem to figure it out. Does anyone have a step-by-step guide on opening a .sdf file within Visual Studio 2017?

Edit:

It has come to my attention that there is some confusion, allow me to clarify. I would like to open a SQL Server Compact Edition file (.sdf). The code for editing the database is already present. I would like to open the file in some sort of viewer so that I can confirm that the columns and rows are being created properly.

For additional clarity, I read that visual studio contains the ability to open .sdf files and to view the contents of said file. .sdf compatiblity was removed from SSMS. Now VS contains a tool for managing .sdf files. I need assistance on how to set this up within Visual Studio 2017

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
philm
  • 797
  • 1
  • 8
  • 29
  • SQL Server uses .mdf files while mysql uses .sdf files. – jdweng Oct 30 '17 at 22:20
  • Having written my answer below, it's now [come to my attention](https://fileinfo.com/extension/sdf) that Pervasive PSQL and dBase also both can use SDF files. To be frank, there's no such thing as a "SQL database". SQL is a language and pretty much every database uses it for querying and the like. You need to find out what the actual database is. When people say "SQL database" they usually are being lazy and mean SQL Server from Microsoft but, as I said in my answer, only SQL Server CE uses SDF files and it is not what people mean when the say SQL to mean SQL Server. – jmcilhinney Oct 30 '17 at 22:47
  • Can someone explain how the question is off-topic? The OP is not asking for any recommendations. He is looking for a guide that will enable him/her to view the contents of a SQL Server CE. I think that this link will satisfy the question: http://www.sokhawin.com/how-to-open-sql-compact-edition-file-sdf-in-visual-studio-or-linqpad/ – codingDude Oct 31 '17 at 14:33

1 Answers1

0

SDF files are for SQL Server CE (Compact Edition). It is a file-based database, unlike SQL Server (or the feature-limited SQL Server Express), which is service-based. Are you sure that it is an SDF file that you want to open? If so then you need the ADO.NET provider for SQL Server CE, which you can get by installing the Microsoft.SqlServer.Compact NuGet package into your project. Once you have access to that provider, you use it in the same way as you would any other ADO.NET provider, e.g.

Using connection As New SqlCeConnection("connection string here")
    '...
End Using

You can get the connection string details at connectionstrings.com.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • ok, I am pretty sure that it is a SQL sever CE file format. The code is there to edit it and everything. I just want to open in a utility to confirm that the rows and columns are being set properly. That is what I am looking for. – philm Oct 30 '17 at 23:36
  • So this has nothing whatsoever to do with VB or C# then. Thanks for wasting our time with your tag spam. – jmcilhinney Oct 31 '17 at 00:07
  • Actually, it does, because I need to do this in both vb and c#. Which are the 2 languages that I am working in right now – philm Oct 31 '17 at 01:19
  • Either you want to open the file in a utility or you want to connect to the database from code. If it's the former then it has nothing to do with VB or C#. If it's the latter then I've already explained what to do. – jmcilhinney Oct 31 '17 at 01:58
  • I am not here to argue. I have a problem that needs solved. If you feel that my tag list needs edited, by all means, please suggest a new tag list. Visual studio has a tool that can directly interface with a sql database with files .sdf. I need to know how to properly set that up in VS – philm Oct 31 '17 at 03:05
  • Again, how does viewing a data file in VS have anything do with VB or C#? That's the issue. You tagged the question with those languages (got here specifically via the VB.NET tag) so reasonable to assume that a solution would involve the use of one or both of those languages. Apparently it does not, so I've wasted my time providing an irrelevant answer. I'm not here to argue either. I'm here to tell you to use the site properly and only use relevant tags when posting questions. You'll save us all time. – jmcilhinney Oct 31 '17 at 03:09
  • OK, I changed the tags – philm Oct 31 '17 at 13:23
  • Sadly, this question is on hold @jmcilhinney I think that you should reread the question a little bit more before posting. The OP does not mention anything about coding and he does have a point, if there is an issue with the tags, suggest a new set that is better suited for the question. No need for arguing. If there is any confusion, ask the OP to clarify before posting. With that said, look at this: http://www.sokhawin.com/how-to-open-sql-compact-edition-file-sdf-in-visual-studio-or-linqpad/ – codingDude Oct 31 '17 at 14:30
  • @codingDude, if someone says that they need to open a file and they tag their question with C# and VB, does that not imply that they want to open the file in C# and/or VB? If someone then insists that the tags are correct because they do need to do it in both VB and C#, does that not imply that they want to open the file in code? I didn't think there was any confusion, thus no need to ask for clarification. The OP has now edited their own tag list but has still not remove the C# tag and has also added the irrelevant SQL. Obviously not interested in helping those whom they want to help them. – jmcilhinney Oct 31 '17 at 21:52