Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys

I have two questions, first one would be how would I go about attaching an sql server database which is located in my application folder using visual basic .net? The current code that have is very basic lol...

"Database=Server-PC\SQLEXPRESS;Initial Catalog=SQLDatabaseFile;Trusted Connection=True"

The second question is the most important of all, On my system I am running Win 7 x64, SQL Server 2008 Developer and programming using Visual Studio 2012.

My second question is, once I run my application and try to connect to a pre-designed database that I created in SQL Server Management Studio, I get the following error...

"The SQL Server Instance returned an invalid or unsupported protocol version during login negotiation", Is there a solution to this problem which does not include upgrading my sql server management studio or sql server to 2012 such as a plugin or minor code change?

Thanks in advance
Posted

1 solution

First Questions Answer...

C#
Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;
Trusted_Connection=Yes;



Second Questions Answer...

I played around with the target framework and figured it out that SQL Server 2008 developer and express is not compatible with .Net framework 4.5 and higher... The solution is to set the target framework of the application I am developing to .Net Framework 3.5.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900