0

I just upgraded from Visual Studio 2015 to 2017 and from SQL Server 2016 to 2017 and.

I have never had any problem with importing a database file into the Visual Studio project with older versions of respective software until today where I got this error:

enter image description here

Andrea
  • 11,801
  • 17
  • 65
  • 72
KBolto
  • 11
  • 1
  • 2
    That looks like a SQL Server 2016 is trying to open a database created by SQL Server 2017. Do you have both versions installed on the server you are connecting to - check your connection string is correct. See https://stackoverflow.com/questions/49899794/what-is-the-version-869-of-sql-server – PaulF Aug 29 '18 at 09:15
  • no, i only have sql server 2017 installed, and the database was created and detached from sql server 2017 – KBolto Aug 29 '18 at 09:32
  • I would make sure of that - the error message is from a SQL Server 2016 instance - the internal version numbers are here : http://sqlserverbuilds.blogspot.com/2014/01/sql-server-internal-database-versions.html – PaulF Aug 29 '18 at 09:39
  • Try using SQL Server Management Studio (SSMS) to view the database. Are you using the MDF file name in your connection string. Never use the MDF filename. Instead connect to the SQL Server and use the ATTACHED database name. You probably not connecting to the latest mdf file that is being used by the database, or connecting to a different instance of the SQL Server. Make sure your connection string matches the instance of the Server you see in the SSMS login window. – jdweng Aug 29 '18 at 09:41
  • Thank you, i have noticed the problem from the info on the link you provided. VS 2017 came out before sql server 2017 thus is dependent on SQL server files of 2016 and earlier. Thanks @PaulF, i just need to find a way of re configuring that – KBolto Aug 29 '18 at 09:44
  • @jdweng I am not using any connection string, I was using the Data source configuration wizard to import the database file as a new data source – KBolto Aug 29 '18 at 09:50
  • When you use a Data Source the connection string is put into the project config file. So open the config file with notepad (it is xml format) and check if the connection string is correct. – jdweng Aug 29 '18 at 09:52
  • @jdweng, Well connecting to the database via connection string works out pretty well, but importing the database file into the project directory brings forth that error – KBolto Aug 29 '18 at 09:56
  • Does the connection string have the mdf filename? You are using a driver in Visual Studio to make the connection which is giving the error. Has nothing to do with the Server. I would open the Solution explorer and right click on the reference that is being used to make the connection to find exactly which driver is being used (dll). – jdweng Aug 29 '18 at 10:40
  • Its fixed. the problem was with visual studio which was using an sql instance for 2016, that is why it was not reading the database file created by sql server 2017. i fixed it by creating a new sql instance for sql localdb 2017 using `sqllocaldb create ` which created the instance with the latest version of MSSQL(2017). – KBolto Aug 29 '18 at 12:14
  • Thank you all for your help – KBolto Aug 29 '18 at 12:15

1 Answers1

1

The problem was with visual studio which was using an sql instance for 2016, that is why it was not reading the database file created by sql server 2017. i fixed it by creating a new sql instance for sql localdb 2017 using sqllocaldb create which created the instance with the latest version of MSSQL(2017). Thank you all for your help.

KBolto
  • 11
  • 1