none
error 26 - Error Locating Server/Instance Specified

All replies

  • Hello,

    The error 26 is a generic one which may mask a different error. So , please, could you provide the full and exact error message ( the message is sometimes in 3 parts, so every part of the error message is useful ) ?

    Please, could you provide the full connection string that you are using in your application ?

    As you are using VC# 2010 Express, you are not allowed to give the name of your SQL Server instance , but you must instead provide the name of the datafile of your database ( because the people who managed VS Express were thinking of the use of user instances only and not the "classical" use of connection with the full name of the instance )

    Please, could you tell whether you are connecting to a remote or local SQL Server instance ( that's to say if your application and your instance are on the same computer ) ?

    Please, could you tell which is he full edition of your SQL Server (Express,Standard,Entreprise,...) ?

    We are waiting for your feedback to try to help you more efficiently.

    Have a nice day

    PS : there is a blog which is the best one about every possible connectivity problem:

    http://blogs.msdn.com/b/sql_protocols/ 

    this blog is managed by the Microsoft team who develop the protocols for SQL  Server Protocols and its articles are really useful,  even if some of them were written 7 years ago.

    http://blogs.msdn.com/b/sql_protocols/archive/2009/09/21/connection-from-a-windows-service-could-be-blocked-by-firewall-even-if-firewall-is-disabled.aspx 

    http://blogs.msdn.com/b/sql_protocols/archive/2008/04/30/steps-to-troubleshoot-connectivity-issues.aspx 

    http://blogs.msdn.com/b/sql_protocols/archive/2008/04/20/could-not-connect-to-x64-named-instance.aspx 

    http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx 

    http://blogs.msdn.com/b/sql_protocols/archive/2006/09/30/sql-server-2005-remote-connectivity-issue-troubleshooting.aspx 

    http://blogs.msdn.com/b/sql_protocols/archive/2006/04/21/581035.aspx

    http://blogs.msdn.com/b/sql_protocols/archive/2005/12/22/506607.aspx  ( see the part error message 5 )

    http://blogs.msdn.com/b/sql_protocols/archive/2005/10/22/sql-server-2005-connectivity-issue-troubleshoot-part-i.aspx ( i don't think that it is your case )

    I hope that you will find something useful in all these links ( most of the articles written about connectiviry errors are using the articles of this blog )


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Friday, March 16, 2012 6:47 PM
  • Thanks for your response. I have been trying almost everything under the sun to try and get this working. This is the main error msg which I get through the data source configuration wizard:

    Unfortunately, I can't even get to the stage where it allows me to read the connection string as it gives the above error msg, but I go through the wizard, add new data source, Database, Dataset, New Connection, Microsoft SQL Server Database File, then I select the .mdf file from 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA'.

    My application and instance are on the same computer so I am guessing this is a local connection.

    My SQL server edition is SQL Server 2008 R2 Developer.

    Wow. This is not an easy problem to resolve...

    Friday, March 16, 2012 8:15 PM
  • Hello,

    Please, could you tell if your problem is occuring in the wizard creating the datasource in your VC# 2010 Express ?

    Have a nice day

    PS : in VC# Express, you have to provide the datafile of the database ( whith .mdf as extension ). Maybe a stupid question, but are you sure that the datafile name is correct ?

    use SQL Server Management Studio Express (SSMSE)  to get the full and correct filename :

    in SSMSE , after having connected to your SQL Server instance, in the left panel,

     - click on the name of the instance to develop all the nodes

     - click on the node to develop the databases name

    - right-click on the name of your database and click on "Properties", in the new form you should see the name of your datafile (.mdf) in the right panal.

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


    Friday, March 16, 2012 8:28 PM
  • Yeah the problem is definitely in the wizard. The database I was trying to link to is in this file path: 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F1_2011-3.mdf'. I am not sure I understand what you wrote about the nodes but the db is called F1_2011-3 in SSMSE.

    In a separate development I easily got a connection in VWD 2010 Express as it is allowing me to select the data source as 'Microsoft SQL Server'. Visual C# does not appear to have this option - I can only get 'Microsoft SQL Server Database File' which seems to be causing this merry-go-round! Is there any way to get a data source option as 'Microsoft SQL Server' in Visual C# as this may resolve my problem?!

    In addition, I'm now worried about all the settings I changed earlier today such as:

    - In Server Properties Security changed Server Authentication from 'Windows Authentication mode' to 'SQL Server and Windows Authentication mode'

    - In Surface Area Configuration changed everything to True except ServiceBrokerEndpointActive, SqlMailEnabled and WebAssistantEnabled (says not available). Did not export current state as policy.

    - netsh advfirewall firewall add rule name = SQLPortdir = inprotocol =tcp action =allow localport = 1433remoteip =localsubnet profile =DOMAIN

    - 'SQL Browser Service EXE' and 'SQL Server Windows NT - 64 bit' are all on public in the firewall.

    I am wondering if some of these changes were unecessary and may compromise the security of my operating system (W7 HP SP1) without actually resolving the problem...

    Friday, March 16, 2012 9:25 PM
  • Hello,

    I have tested VWD already and i know that it has a behaviour slightly different from the VC# ( it is the same thing for both versions 2008 and 2010 ).

    I would suggest you in the datasource wizard to click on the button Advanced . You will see a new form with nearly all the possible properties of the connection string. Go to the bottom of the listview and have a look at the last property ( User Instance).If it is set to true, change it to false ( click on the end of the cell containing false, and select false ). You will avoid the "classical" pitfalls of the user instance ( the user instance feature is a nice feature but really difficult to understand and to use, with a major problem : it can be used only with a SQL Server Express instance, if you need to upgrade it to a not free edition like Standard, your application will not working ).

    Please, could you test this little modification ?

    Please, could you tell us how you have created your database ( with SSMSE or with VC# ) ? If you have used VC#, it is unable to create a "real" database, but only "user instance" database.You can see it in your SSMSE, but the way is not easy ( and sometimes tricky ).

    A little advice : forbid the use of user instance on the server level ( in SSMSE, right-click on the SQL Server name, select Facets, in the new form, select  the facet named "Server Configuration", in the listview, search the property UserInstancesEnabled to false and click on the OK button ).Be careful as it is for all databases of your SQL Server instance.But user instances are depreciated since SQL Server 2008 , and it is condemned to death ...

    Have a nice day

    PS : if you need to use user instance ( a depreciated feature which will not be supported in the version following Denali or 2012 ), a moderator will move ( with your agreement ) your thread towards the SQL Server Express Forum ( it is an habit to treat this kind of question because user instance is a feature specific to SQL Server Express ) where i think that the members of the SQL Server Express Team have a big look at all the threads.


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Saturday, March 17, 2012 9:06 AM
  • OK - The database itself (the .mdf and .ldf files) was copied from SQL Server 2005 and had been created in SSMSE. It is currently operating with an MS Access 2003 form as a front end to SQL Server 2008 R2 Developer.

    I changed the User Instance to False but am getting the same results. This is the connection string:

    Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F1_2011-3.mdf";Integrated Security=True;Connect Timeout=30;User Instance=False

    In relation to the Facets I am unable to change the UserInstancesEnabled as it says: "Property value 'UserInstancesEnabled' is not available". 

    I tried to use another .mdf file as a test to try another db but got this msg: "You don't have permission to open this file. Contact the file owner or an administrator to obtain permission". I am not sure how to sort this out. I tried changing Auto Close to True in the Properties-Options of the database but it didn't make any difference.

    Will installing SP1 for VS2010 help to resolve this problem?

    Sunday, March 18, 2012 12:09 AM
  • Hello,

    I am sorry not to reply before, but as it was Sunday, i was away in Normandy ( a good day in the country is always good for me as i am living 4 miles from the center of Paris ).

    - to be sure that your connection to a SQL Server instance is working, the Visual Studio SP1 is necessary for the Visual Studio 2008 and the Visual Studio 2010 ( any language ). I have tested that 2 weeks ago, when i have reinstalled my drive C: and the operating system ( be careful  to apply it for any Visual Studio Express and not to forget the security update but it cannot  be installed in the same time than the SP1 ).

    - i suppose that your SQL Server MSSQLServer instance is not a SQL Server Express Edition because you have the message "Property value 'UserInstancesEnabled' is not available". As I wrote already, this feature is supported only by the Express Edition, not by Web,Workgroup,Standard,Entreprise,... editions ( that's to say the editions which are not free )

    - to get the name of the edition of a SQL Server instance, it is simple ( but not evident to find except if you are using SMO ). In the left panel ( Objects Explorer ), right-click on the name of the instance, select the Facets item of the contextual menu, and in the new form, select Informations on the server ( not sure that it is the good translation as I have a French Developer Edition ), search the values for Edition ( for me i see Developer Edition , its value is a string ) and EngineEdition ( for me i see EntrepriseOrDeveloper, its value is an enumeration  ). You could find the last installed Service Pack in the value of ProductLevel. For the short name of the SQL Server instance, you will find it in the Installation Parameters facet, in the property named InstanceName ( not evident to find, i know ),it will return an empty string  if it is a no-named instance ( or default instance , only one on a computer ), but i think that it is not possible for an Express edition ( to check ). You should find the name of the computer on which the SQL Server instance with the NetName or ComputerNamePhysicalNETBIOS properties ( Informations on the server )

    - please, you wrote that "The database itself (the .mdf and .ldf files) was copied from SQL Server 2005 and had been created in SSMSE". I am not sure to have understood ( always my problems with english... ) but i am not sure that it would be the way. I would prefer to do a full backup oof the database on the SQL Server 2005 instance ( with SSMSEE ) , you copy your backup file on your new computer ( if you use a DVD/CD for the transfer, don't forget to mark the copied backup file as Read-Write, not ReadOnly ) and use the SSMS to restore your backup ( you may change the folder where to install your data and log files and even the name of your database )

    - your connection string

    "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F1_2011-3.mdf";Integrated Security=True;Connect Timeout=30;User Instance=False"

    I have a doubt with your data source ( the full name of your SQL Server ), if you have attached/restored your database on another computer, i think that "Data Source = NetName" would be better ( NetName is the value of the NetName i wrote about in a preceeding part )

    - you have a problem of permissions ( maybe in ReadOnly ) with the .mdf and .ldf , which is logical ( C: is checked especially from Vista ).If i have understood, your database should be named F1_2011-3 ( from the name of the .mdf file ). I am using VC#  and VB Express 2010, but i disagree to the data tools provided by this edition ( too many problems with them ). Moreover, if you change the structure of your database, you have to recompile all the auto-generated part and 3 times, i lost all these auto-generated parts . I prefer to write the code by myself ( especially because  i need some optimizations not supported by the VS Express Tools ).

    I hope you will excuse me for the presentation of this post ( i know, it is not my strong point ). I have some tests to do between my own computer ( XP SP3 SQL Server 2008 SP3 all 32-bits ) and another computer ( Windows 7 Home Premium SQL Server 2008 R2 SP1 all 64-bits ), but the last one is busy with my younger boy ( he plays on it the whole week-end so i havee to wait for Monday to get it free )

    Don't hesitate to post again for more help or explanations ( i know that my english is not easy to understand , i am trying to better it but i am nearly 65 so it is not easy ... )

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Sunday, March 18, 2012 7:20 PM
  • Many thanks for all your feedback. This is something I definitely need to take the time to look into.

    I took the time to install SP1 for VS2010.

    It looks as though there are various issues; edition issues, permissions, setup and copying files from SQL Server 2005. In fact I tried to do the same test with AdventureWorks for SQL Server 2008 R2 and still the same problems.

    I am having no problems with VWD from what I can see, so this could also be a VC# issue.

    This is what I have so far: Edition - Developer Edition (64-bit), Engine - EnterpriseOrDeveloper, ProductLevel - SP1, InstanceName - empty string, NetName/ComputerNamePhysicalNetBIOS - (my personal computer name).

    The laptop that had SQL Server 2005 has now had its operating system reinstalled, so there is not much I can do, but will back up properly if the situation arises again...

    In VWD and VC# Tools > Options, the Data Connections SQL Server InstanceName are defaulted to SQLEXPRESS. Changing this to MSSQLSERVER, an empty string or to (my personal computer name) made no difference.

    Let me find a spare moment to look at this again during the week as this type of investigation looks like it will take me many more hours!!!...

    Nevertheless many thanks for all the time you have put into this. I'm just astonished as to how this process is simplified in VWD and so complicated in VC#.



    Sunday, March 18, 2012 9:27 PM
  • Hello,

    Just a little remark before going to bed ( it's midnight for me ) : VWD is done to produce ASP applications, where the user instance is useless , it is why you must provide the name of the database, not the the name of the datafile.On contrary, VC# and VB ( Express Edition ) have been conceived for the use of user instance where the name of the datafile (.mdf) is necessary with the creation of a database stored in the same folder as the application.

    I think that you have installed the Developer as a no-named instance, in this case , the data souce must contain only the name of your computer ( if your developer instance is local, not remote, you may replace the name of your computer by (local) or . , the same character marking the end of a sentence ). Please, could you test this modification in the connection string ?

    I would suggest to test with the Class SqlConnection of the namespace System.Data.SqlClient before using the Data menu of your VS. And to use the auto-generated code produced thru the Data menu only when you will have understood how SqlConnection , SqlCommand and similar classes are working. I am using VC# ( and VB even i don't like it, too complicated ) since VS 2003 and i have solved very quickly most of my problems with this method.

    If you want to understand the connection string and its properties, try to use the class SqlConnectionStringBuilder to build a connection string. To get the connection string , use the ToString() method of this class to get it and use the constructor of SqlConnection(connectionString). The advantage is important : the ToString() will throw an exception if the connection string is invalid. Other advantage : you may use the intellisense to load the properties of the SqlConnectionStringBuilder

    SqlConnectionStringBuilder _builder = new SqlConnectionStringBuilder();

    _builder.DataSource = "Alpha3" ;  // if the computer name where the SQL Server has been installed is Alpha3

    // if it is not a default instance, that's to say with the name MySqlServer _builder.DataSource = Alpha3\MySqlServer   \ and not / erroneous

    _builder.IntegratedSecurity = true;

    _builder.InitialCatalog = "F1_2011-3"; // if the database name is F1_2011-3

    _builder.ConctTimeout = 30;

    String p_s = _builder.ToString(); //

    SqlConnection _sqlconn = new SqlConnection(p_s);

    I had no time to install a no-named instance and the CodePlex databases ( i will do it today 00:49 for me ) and i will post the code today

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Sunday, March 18, 2012 11:49 PM
  • OK - a lot of this is quite advanced for me!

    In the Add Connection Advanced Properties DataSource properties there is only the option for '.\SQLEXPRESS' or '.' If I put in '.', I get a msg "The user instance login flag is not supported on this version of SQL Server. The connection will be closed". If I change this to '.\(my computer name)' which is the result of

    SELECT @@SERVERNAME

    I get my original error message.

    Where do I put the connection string code in VC# i.e. which template do I use?

    Many Thanks.

    Monday, March 19, 2012 10:32 AM
  • Hello,

    I have installed a SQL Server Express 2008 R2 as a no-named ( or default ) instance on another computer ( Windows 7 Home Premuim SP1 ) with the CodePlex Databases Samples (SR1) for SQL Server 2008 R2 ( i can use it only after midnight or sometimes between 10 am upto 16 pm unluckily )

    I created a little program ( a console application ) in VC# Express 2010 with the following code :

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Text;
    namespace Cons_ConnectExpressDefault
    {
         class Program
         {
              static void Main(string[] args)
              {
                   String p_s = "";
                   Int32 p_spid = 0;
                   SqlCommand p_sqlcmd = null;
                   SqlConnection p_sqlconn = null;
                   p_s = "Trying to connect to the 'default' SQL Server 2008 R2 Express instance on the AD-PC computer";
                   Console.WriteLine(p_s);
                   p_s = "Connection in SQL Server Authentification with the login = Paddy";
                   Console.WriteLine(p_s);
                   SqlConnectionStringBuilder p_scsb = new SqlConnectionStringBuilder();
                   // To make easier the search of the process in SSMSE
                   p_scsb.ApplicationName = "TestRemoteConnection";
                   // 60 seconds is long but it would avoid problems with the AutoClose property of the database
                   p_scsb.ConnectTimeout = 60; 
                   // name of the SQL Server instance 
                   // for the SQLExpress1 instance use "AD_PC\SQLExpress1" in the next line
                   p_scsb.DataSource = "AD-PC";
                   // name of the database
                   p_scsb.InitialCatalog = "AdventureWorksLT";
                   // SQL Server Authentification compulsory between 
                   // a XP SP3 and a Windows 7 Home Premium on a workgroup
                   p_scsb.IntegratedSecurity = false;
                   // MaxPoolSize at leaset > MinPoolSize + 1
                   p_scsb.MaxPoolSize = 3;
                   p_scsb.MinPoolSize = 1;
                   // I prefer to avoid the use of MARS
                   p_scsb.MultipleActiveResultSets = false;
                   p_scsb.UserID = "Paddy";
                   p_scsb.Password = "********";
                   p_scsb.Pooling = true;
                   // The connection is not for Replication
                   p_scsb.Replication = false;
                   p_scsb.UserInstance = false;
                   Console.WriteLine("Connection string : " + p_scsb.ToString());
                   p_sqlconn = new SqlConnection(p_scsb.ToString());
                   p_sqlconn.Open();
                   Console.WriteLine("Connection to {0} of {1} is open",p_sqlconn.Database,p_sqlconn.DataSource);
                   p_sqlcmd = new SqlCommand();
                   p_sqlcmd.CommandText = "SELECT @@SPID";
                   p_sqlcmd.CommandTimeout = 30;
                   p_sqlcmd.Connection = p_sqlconn;
                   p_spid = Convert.ToInt32(p_sqlcmd.ExecuteScalar());
                   Console.WriteLine("SPID : {0}",p_spid);
                   Console.Write("Type on any key to stop the program");
                   p_s = Console.ReadLine();
                   p_sqlconn.Close();
                   Console.WriteLine("Connection closed bye-bye...");
              }
         }
    }

    The result is ( the test application was on the my own computer with XP Pro SP3

    Trying to connect to the 'default' SQL Server 2008 R2 Express instance on the AD
    -PC computer
    Connection in SQL Server Authentification with the login = Paddy
    Connection string : Data Source=AD-PC;Initial Catalog=AdventureWorksLT;Integrate
    d Security=False;User ID=Paddy;Password=*******;Pooling=True;Min Pool Size=1
    ;Max Pool Size=3;MultipleActiveResultSets=False;Replication=False;Connect Timeou
    t=60;Application Name=TestRemoteConnection;User Instance=False
    Connection to AdventureWorksLT of AD-PC is open
    SPID : 53
    Type on any key to stop the program

    With SQL Server Express 2005, i never succeeded to create a default ( no-named ) instance.Today I discovered that it is possible with SQL Server 2008 R2 Express with a SQL Server service = MSSQLSERVER ( as logical ).Moreover, user instance does not support remote connections ( it can be used only with local instances )

    I will do some tests to see how it is possible to use ( with my VC# 2010 Express ) the menu Data and the form DataSource to connect to a remote computer. I never have done it as i prefer to rely on my code than on the data wizard provided with VC#/VB  Express Editions

    As i wrote before, user instance is supported by the Express editions, so the use of the User Instance = True in the connection string is throwing an exception with a Developer Edition

    In the Data Source property of your connection , you have only to put the name of the computer where the SQL Server has been installed ( idem for the DataSource property of my code ) and i will post my results ( positive or negative and possible other solutions )

    Don't hesitate to post again for more help or explanations or informations making easier my searches

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Tuesday, March 20, 2012 3:09 PM
  • Thanks for all the time and effort you are putting into this...

    I can change the DataSource name from Tools > Options > Database Tools > Data Connections > SQL Server Instance Name (blank for default): in VC#. This name then appears in the Add Connection > ... > Advanced > Data Source when running through the Add Connection wizard. None of the changes made here i.e. changing the Data Source to my computer name or from the default SQLEXPRESS to MSSQLSERVER made any difference. Neither does changing the User Instance from True to False.

    If this is a Developer edition issue then I am wondering if there is a workaround to the problem.

    I would be interested in the results of your wizard based test!

    Tuesday, March 20, 2012 9:47 PM
  • Hello,

    I have tried from the VC# Express 2010  menu Data ==> Add a new connection ==> Database ==> DataSet. In the form labelled Add a connection, i was annoyed by the fact that the "default" provider is for SQL Server Compact 3.5 as if the Express Edition neglects SQL Server Express or Developer. To get the datafile (.mdf), i have a big problem as the SQL Server has been installed with the default parameters, the directory where the .mdf file resides is unavailable ( no access permissions ). So my try has failed and i don't think that there is a way to avoid this pitfall.

    During the last TechDays in Paris, i attended a session with members of Visual Studio team in France about the problems occuring with Visual Studio. Among the problems i have evoked , there was a question about the DataSource with SQL Server when using the Express VS and i have understood that this problem might not be solved for the next version of Visual Studio ( this using .Net Framework 4.5 ) but only with the next one.

    The only solution given by the VS team was : use VS Pro and no more problem. My answer has been : in this case, what is the use of VS Express , a simple toy surely ? They were annoyed as they have no way to incite the Redmond Visual Studio Team to change their choices. Bad luck for the VS Express Editions and for us.

    According what i have understood, VS VWD Express is nearly the same as the version of VS Pro, it is why it's working for you.

    If you want , i can move your thread towards a forum related to Visual Studio where it could be seen by members of the Visual Studio Team  ( a way to push them to change their choices for the next Visual Studio , i think that it is not too late )

    I have done the same test with my Visual Studio Standard 2008. No problem with the connection with a database residing on a Windows 7 Home Edition. But it is not using .Net 4.0 and this edition has disappeared with VS 2010. A bad choice ( i would think : a stupid choice for us ).

    I am sorry not to provide a solution to your problem ( except with a VS Pro which is far to be free and too much costly for me )

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Wednesday, March 21, 2012 1:34 PM
  • Many thanks for another thorough investigation.

    I am astonished that it is not possible to get a connection from VC# 2010 Express to SQL Server 2008 R2 Developer and would definitely be happy for you to move this thread to the Visual Studio forum.

    Unfortunately, like you, I cannot afford the Professional version and there is no point in me installing a trial version which will expire.

    I was in a bookshop today and thought I had found something in a book called 'C# Database Basics' relating to the Data Source (i.e. using .\\ instead of .\ before the SQL Server Instance Name) but no luck...


    • Edited by meridius10 Wednesday, March 21, 2012 11:22 PM
    Wednesday, March 21, 2012 11:22 PM
  • Hello,

    Just a short reply about the book. I would suggest :

    - ADO.Net 3.5 Cookbook  Author Bill Hamilton ( O'REILLY is the publisher ) about 55 US $

    really interesting

    - Programming Microsoft ADO.Net 2.0 Core Reference ( David Sceppa ) Microsoft Press

    old but clear and complete

    - i will buy a book from Microsoft Press about a certification for Data Access . I have read shortly it , one of the best ones i have seen : many informations, numerous pieces of code

    For your problem, i remember that i participated to an old thread ( 2007 or 2008 ) about the way to change change the connection string in case of a change of the name of the SQL Server instance. If my memory is not too bad, the connection string build by the datasource wizard is stored in the app.config. I think to remember that it is possible to modify the name of the DataSource ( MyComputer\MyInstance) and even the name of the database in the app.config when the application has been created on an instance or /and database different from the real user ( but if you do an install, the bad connection string will be regenrated on each compile , so you have to change it on the user computer ).

    Not a pleasant solution but it permits to use an instance + database with different names from the user computer on which the application will work.

    I have to retrieve this thread and it is not easy as this forum gets around 15 new threads/day , around 4000 threads to look at... ( i will begin to-day ( it is 01:03 AM )

    Have a nice day 


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Thursday, March 22, 2012 12:03 AM
  • Don't worry too much about it and I don't mind if this takes time to resolve itself. At the end of the day, I have an Access front end and there is a limited amount of time we can all put into resolving the problem. We may resolve it, but I don't mind prolonging until we get the result, as we all have to juggle our various priorities around!

    At the end of the day it may very well be that VWD is a better application for this as ultimately the goal is to have an online database, although I am not sure how a user form would be developed which is similar in style to an Access front end.

    I am doing this extension of the project on a voluntary basis for archaeologists so am using the opportunity to learn new technologies.

    Thursday, March 22, 2012 9:25 AM
  • did you checked host file name? Do you have entry in that?
    Thursday, March 22, 2012 5:37 PM
  • If you mean what is in the connection string above, the answer is yes.

    Even if I try to run it with AdventureWorks, I get the same problem. This is the connection string for it:

    Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks_Data.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True

    with the same error message (26). On top of it all, I need to run VC# in administrator mode to be allowed a connection to the .mdf's.

    Thursday, March 22, 2012 6:46 PM
  • Hello,

    Data Source = .\SQLEXPRESS ==> named instance with a "short name " equals to SQLEXPRESS

    AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks_Data.mdf" is corresponding to the AdventureWorks database which belongs to a no-named instance.

    If you want to use the user instance , you have not to provide the Data Source. If you want to provide the Data Source with a no-named instance Data Source = .;AttachhDbFilename = ...

    But , with my poor english, i may misunderstand something

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Thursday, March 22, 2012 9:57 PM
  • OK - I opened VC# in administrator mode (Run as Administrator).

    The Data Connections SQL Server Name is now blank, or 'blank for default' as is written in Tools > Options > Database Tools > Database Connections.

    The connection string is now:

    Data Source=.;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks_Data.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True

    The error msg in VC# has changed to: The user instance login flag is not supported on this version of SQL Server. The connection will be closed.

    If I change the Data Source to my computer name I get the same error msg as before.

    Update:

    I changed the User Instance to False:

    Data Source=.;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks_Data.mdf";Integrated Security=True;Connect Timeout=30;User Instance=False

    After pressing the Test Connection button I got a Test Connection succeeded msg

    However, after this I got a msg: The ability to open this connection is not supported in this edition of Visual Studio

    What fun!

    P.S. Update on post below!....


    • Edited by meridius10 Friday, March 23, 2012 11:16 AM
    Friday, March 23, 2012 10:40 AM
  • Bigger problem now!

    In VC# when I try to connect a file I get a 'This file is in use. Enter a new name or close the file that's open in another program'.

    In SQL Server 2008 R2. I got this msg when trying to open both the databases:

    TITLE: Microsoft SQL Server Management Studio
    ------------------------------

    Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476

    ------------------------------
    ADDITIONAL INFORMATION:

    Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\AdventureWorks_Data.mdf". Operating system error 32: "32(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2500&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476

    ------------------------------
    BUTTONS:

    OK
    ------------------------------

    Both the databases have been replaced by:

    Now I must prioritise trying to recover my databases!!!....



    • Edited by meridius10 Friday, March 23, 2012 11:15 AM
    Friday, March 23, 2012 11:13 AM
  • Hello,

    When i see your screenshot, i see 4 problems  belonging to 2 groups :

    1st group for the databases AdventureWorks and F1_2011-3 : no + before the names of these databases means ( usually ) that these databases are not accessible

    2nd group for the both databases of which the names are beginning by C:\Program Files . These both databases have the names of the datafiles (.mdf) of the databases without a + before their names.

    It seems that it is a problem that i obtained after having forgotten to set user instance = false in the connection string. I posted on a forum and i applied the solution , right-click on the name of the database and select the drop ( or delete i don't know the exact english term as i have French SQL Servers )

    First, we need to know the full and exact edition of your "ill" SQL Server instance.

    For that , connect to your SQL Server instance corresponding to the screenshot you provided. Right-click on the name of the SQL Server instance.In the conceptual menu, select Facets. In the new form, select the facet approxamitively named  Server informations and give us the values for the 3 following properties : EngineEdition, NetName,VersionString.

    It is only to identify whether it is an Express or not edition

    Right-click on each of the  4 databases i wrote about at the beginning of this post. Select Facets, and in the new form select the Database facet and give us the values for the 8 following properties : AutoClose, CompatibilityLevel, CreateDate, IsAccessible, Name, ReadOnly , Status , Version

    According the values you will provide, i ( or a moderator ) will move your thread towards the SQL Server Express Forum where i think someone of the SQL Server Express Team will try to save your databases ( if it is possible ).

    And please, stop to use the Data Wizard to build a DataSource with your VC# , it is unable to use correctly a SQL Server ( Express or Edition ) . To connect correctly and without spoiling your databases, i know only one solution : ignore the Data Wizard , use the SQLConnectionStringBuilder class to build your connection string and to create your SqlConnection. And afterwards, you will have to code everywhere related to SqlCommand and other classes of the System.Data.SqlClient namespace. And it is an useful way as you have to learn but i needed only 2 months to understand how this namespace is working ( with goods books i provided the ttles of 2 ones )

    We are waiting for your feedback  to try to help you more efficiently.

    Have a nice day

    PS : if you get the message "user instance feature is not supported on this edition", it means the the SQL Server is not an Express edition ( it is why the value of the EngineEdition is so important ).

    It is possible that you cannot get access to the databases without a + before their names : it means that the database is badly ill ( usually a part of its structure is missing , a problem which has only one solution : to drop it , it is the answer that i received for a similar problem from the Getting Started With SQL Server Forum and i thank very much the person who gave me this solution )


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Friday, March 23, 2012 7:35 PM
  • OK here is the info:

    Engine Edition - EnterpriseOrDeveloper
    NetName - mycomputername (sorry, I won't give the full name)
    VersionString - 10.50.2500.0

    DB1 (AdventureWorks)

    Ran as administrator but still this msg:

    AdventureWorks:

    msg: TITLE: Microsoft SQL Server Management Studio
    ------------------------------

    You do not have permission to view facets in [AdventureWorks]. (Microsoft.SqlServer.Management.Dmf.UI)

    ------------------------------

    DB2 (F1_2011-3)

    Also ran as administrator but still this msg:

    F1_2011-3:

    TITLE: Microsoft SQL Server Management Studio
    ------------------------------

    You do not have permission to view facets in [F1_2011-3]. (Microsoft.SqlServer.Management.Dmf.UI)

    -----------------------------

    DB3 (C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\ADVENTUREWORKS_DATA.MDF):

    AutoClose - False
    CompatibilityLevel - Version100
    CreateDate - 23/03/2012 10:32
    IsAccessible - True
    Name - C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\ADVENTUREWORKS_DATA.MDF
    ReadOnly - False
    Status - Normal
    Version - 661

    DB4 (C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F1_2011-3.MDF):

    AutoClose - False
    CompatibilityLevel - Version90
    CreateDate - 23/03/2012 11:39
    IsAccessible - True
    Name - C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\F1_2011-3.MDF
    ReadOnly - False
    Status - Normal
    Version - 661

    There is no problem with access to DB3 & DB4 as they have a + before their name. In fact (and I need to run this by you), I renamed DB4 to F1_2011-3-2 just as a test and changed the connection to my Access 2003 front end and it appeared OK. Does that mean that it is OK as this could be a better solution than something more complicated which results in potential data loss?

    Don't worry, no more wizards. I am very tempted to move to VWD for this project as the goal is to have an online front end to replace the Access form.

    Friday, March 23, 2012 8:21 PM
  • Hello,

    I would suggest this link

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/448f60ce-6b7d-48bb-b460-cd4554f6c466 

    you should find some usefull explanations in a better english than mine.

    I will have to reproduice your problem but not today ( 23:15 for me ).

    I have the feeling that you have found the good way to solve your problem.

    The idea of the use of VWD is far to be stupid, but simply clever ( you would avoid many problems.

    Have a nice day

    PS : maybe also this link

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/448f60ce-6b7d-48bb-b460-cd4554f6c466 even if the last post could be considered as aggressive


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


    Friday, March 23, 2012 10:18 PM
  • Thanks for the links. I will take a look at them when I get the time. In the meantime I have deleted DB1 & DB2 and renamed DB3 & DB4 to their original names. DB4 seems OK and the Access front end will do for now.

    If it wasn't for finances, I would have installed the Professional edition and perhaps not had these problems.

    I hope that other users won't have to go through all this!...

    Saturday, March 24, 2012 8:28 AM