Db connect problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Lux

    #1

    Db connect problem

    I'm fairly new to c#, but not new to programming. I'm tasked with rewriting
    our Gupta/Sqlwindows apps (5 years worth of development) in dot Net. The
    main reason is that virtually no one knows the language, which is
    unfortunate because it's very simple to get windows created and rolled out.

    I downloaded C# (orcas) express and had created a SqlServer 2005 database
    (locally, ie not on a server) and moved some of our production data into it
    just to see if I could start coding some of the "simpler" tables. I'm not
    planning on using express in the long run, I'm just evaluating the software
    at this point.

    I can't connect to the database. When I go to Database Explorer and clik on
    Data Connections, I fill in the dialog with the .mdf that I want to attach
    to. It comes back with
    "...When connection to SQL Server 2005, this failure may be caused by the
    fact that under the default settings SQL Server does not allow remote
    connections. (provider: SQL Network Interfaces, error: 26- Error Locating
    Server/Instance Specified)"

    I've checked to see that remote connections are specified and that I have
    the correct protocols enabled. I can attach and query the tables in SQL
    Server Management Studio 2005 just fine.

    What, perhaps, am I doing wrong?


  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Db connect problem

    Hi,

    "Peter Lux" <pete.lux@thehe ritagegrp.comwr ote in message
    news:enctdU87HH A.5164@TK2MSFTN GP05.phx.gbl...
    I downloaded C# (orcas) express and had created a SqlServer 2005 database
    (locally, ie not on a server)
    You will be better off with the 2005 version of the IDE , Orcas is still in
    beta.
    and moved some of our production data into it just to see if I could start
    coding some of the "simpler" tables. I'm not planning on using express in
    the long run, I'm just evaluating the software at this point.
    >
    I can't connect to the database. When I go to Database Explorer and clik
    on Data Connections, I fill in the dialog with the .mdf that I want to
    attach to. It comes back with
    "...When connection to SQL Server 2005, this failure may be caused by the
    fact that under the default settings SQL Server does not allow remote
    connections. (provider: SQL Network Interfaces, error: 26- Error Locating
    Server/Instance Specified)"
    You do not connect to a particular mdf. you connect to the server, you enter
    the server location, username/password and then you will see a list of the
    databases in that server.



    Comment

    • Peter Lux

      #3
      Re: Db connect problem

      "Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
      message
      You do not connect to a particular mdf. you connect to the server, you
      enter the server location, username/password and then you will see a list
      of the databases in that server.
      The dialog that I get asks for a "Database file name (new or existing)" and
      the browse button specifically looks for an .mdf.
      You will be better off with the 2005 version of the IDE , Orcas is still
      in beta.
      I have a version of c# 2005 express (in addition to the "Orcas") and still
      get that error 26 message.

      Should I have to uninstall "Orcas"?


      Comment

      • WenYuan Wang [MSFT]

        #4
        Re: Db connect problem

        Hello Peter,
        Thanks for Ignacio's reply.

        Based on my experience, it seems like SQL Server Configuration issue.
        Would you please check if SQL Browser service and SQL Server (SQLEXPRESS)
        service are running on your server?

        Start|All Programes|Micro soft SQL Server 2005|Configurat ion Tools| SQL
        Server Configuration Manager.
        Select "SQL Server 2005 Services" node in the left panel.
        Start SQL Server Browser
        Start SQL Server (SQLEXPRESS)

        C# 2005 express always attaches the mdf file by SQLExpress service on local
        machine.

        Please try the above method and let me know if this method works on your
        side. I will follow up. It's my pleasure to assist you.
        Have a great day,
        Best regards,

        Wen Yuan
        Microsoft Online Community Support
        =============== =============== =============== =====
        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        • Peter Lux

          #5
          Re: Db connect problem

          Thanks for responding, this is sooo confusing.

          I think I should tell you what my local config is. I've got SqlServer 2005 running on my machine because I attach to our Great Plains SqlServer that is also 2005. I don't believe I have Sql Server EXPRESS installed. It shouldn't make a difference even if I try to attach from c# 2005 (not the "Orcas" edition)

          In the configuration, I have 5 services running (start mode is Automatic):

          SQL Server Integration Services

          SQL Server FullText Search (MSSQLSERVER)

          SQL Server (MSSQLSERVER)

          SQL Server Browser

          SQL Server Agent (MSSQLSERVER)


          In the protocols section, the only one that ISN'T enabled is VIA.

          Please, let me know what I'm missing.

          "WenYuan Wang [MSFT]" <v-wywang@online.m icrosoft.comwro te in message news:AArO4fG8HH A.5532@TK2MSFTN GHUB02.phx.gbl. ..
          Hello Peter,
          Thanks for Ignacio's reply.

          Based on my experience, it seems like SQL Server Configuration issue.
          Would you please check if SQL Browser service and SQL Server (SQLEXPRESS)
          service are running on your server?

          Start|All Programes|Micro soft SQL Server 2005|Configurat ion Tools| SQL
          Server Configuration Manager.
          Select "SQL Server 2005 Services" node in the left panel.
          Start SQL Server Browser
          Start SQL Server (SQLEXPRESS)

          C# 2005 express always attaches the mdf file by SQLExpress service on local
          machine.

          Please try the above method and let me know if this method works on your
          side. I will follow up. It's my pleasure to assist you.
          Have a great day,
          Best regards,

          Wen Yuan
          Microsoft Online Community Support
          =============== =============== =============== =====
          This posting is provided "AS IS" with no warranties, and confers no rights.
          >

          Comment

          • Guest's Avatar

            #6
            Re: Db connect problem

            Hi Peter

            What OS are running on?

            If you are using Vista, have you tried running Orcas as an administrator?
            You cannot attach a new MDF file to a SQL Server 2005 database, unless you
            are running as an admin.

            --
            Ged Moretta
            Senior Software Engineer
            AppSense Ltd
            Founded in 1999, AppSense was a global leader in secure user environment management with more than 3,500 customers securing over 8 million endpoints.


            -----------------------------------------------------------------------
            This signature isn't automatic. I have to type it manually every time.


            "Peter Lux" <pete.lux@thehe ritagegrp.comwr ote in message
            news:u%23QXq1I8 HHA.2004@TK2MSF TNGP06.phx.gbl. ..
            Thanks for responding, this is sooo confusing.
            I think I should tell you what my local config is. I've got SqlServer 2005
            running on my machine because I attach to our Great Plains SqlServer that is
            also 2005. I don't believe I have Sql Server EXPRESS installed. It shouldn't
            make a difference even if I try to attach from c# 2005 (not the "Orcas"
            edition)
            In the configuration, I have 5 services running (start mode is Automatic):
            SQL Server Integration Services
            SQL Server FullText Search (MSSQLSERVER)
            SQL Server (MSSQLSERVER)
            SQL Server Browser
            SQL Server Agent (MSSQLSERVER)

            In the protocols section, the only one that ISN'T enabled is VIA.
            Please, let me know what I'm missing.
            "WenYuan Wang [MSFT]" <v-wywang@online.m icrosoft.comwro te in message
            news:AArO4fG8HH A.5532@TK2MSFTN GHUB02.phx.gbl. ..
            Hello Peter,
            Thanks for Ignacio's reply.
            >
            Based on my experience, it seems like SQL Server Configuration issue.
            Would you please check if SQL Browser service and SQL Server (SQLEXPRESS)
            service are running on your server?
            >
            Start|All Programes|Micro soft SQL Server 2005|Configurat ion Tools| SQL
            Server Configuration Manager.
            Select "SQL Server 2005 Services" node in the left panel.
            Start SQL Server Browser
            Start SQL Server (SQLEXPRESS)
            >
            C# 2005 express always attaches the mdf file by SQLExpress service on
            local
            machine.
            >
            Please try the above method and let me know if this method works on your
            side. I will follow up. It's my pleasure to assist you.
            Have a great day,
            Best regards,
            >
            Wen Yuan
            Microsoft Online Community Support
            =============== =============== =============== =====
            This posting is provided "AS IS" with no warranties, and confers no
            rights.
            >

            Comment

            • Peter Lux

              #7
              Re: Db connect problem


              <Gedwrote in message news:eBOGE8I8HH A.4584@TK2MSFTN GP03.phx.gbl...
              Hi Peter
              >
              What OS are running on?
              >

              Windows XP Pro svp 2.
              I know at one time, I attached to SqlServer 2000 (or 2003) from VB.net 2003
              on my local machine.
              Is there, maybe, I firewall setting or something like that I'm missing? I am
              the local admin on my machine and like I said, I have all the processes up
              and running. I can connect AND query thru Management studio.


              Comment

              • WenYuan Wang [MSFT]

                #8
                Re: Db connect problem

                Hello Peter,

                According to your desption, you are using Visual C# 2008 express and SQL
                server 2005.(SQL Server 2005 and C# 2008 express are installed on the same
                mathine). You managed to attach to .mdf file in C# 2008 express Databaes
                Explorer. But, Database explorer thowed error message "error: 26 - Error
                Locating Server/Instance Specified" Please correct me if I misunderstood
                anything.

                Regarding to the error: 26 - Error Locating Server/Instance Specified, you
                may check the following article.
                http://blogs.msdn.com/sql_protocols/...work-interface
                s-error-26-error-locating-server-instance-specified.aspx
                [SQL Network Interfaces, error: 26 - Error Locating Server/Instance
                Specified]

                1) Make sure your server name is correct,
                2) Make sure your instance name is correct and there is actually such an
                instance on your target machine.
                3) Make sure the server machine is reachable, e.g, DNS can be resolve
                correctly, you are able to ping the server (not always true).
                4) Make sure SQL Browser service is running on the server.
                5) If firewall is enabled on the server, you need to put sqlbrowser.exe
                and/or UDP port 1434 into exception.

                If the above method doesn't resolve you issue, would you please paste the
                connection string which VS 2008 Express generated? I suspect VS 2008
                express connected to the SQL Server 2005 instance with wrong connect string.

                In "Add Connection" dialog, click "Advanced.. ." button. Connect String
                textbox is at the bottom of "Advanced Properties" dialog.

                Please let me know if there is anything unclear. Have a great day!
                Best regards,

                Wen Yuan
                Microsoft Online Community Support
                =============== =============== =============== =====
                This posting is provided "AS IS" with no warranties, and confers no rights.

                Comment

                • Peter Lux

                  #9
                  Re: Db connect problem


                  "WenYuan Wang [MSFT]" <v-wywang@online.m icrosoft.comwro te in message >
                  If the above method doesn't resolve you issue, would you please paste the
                  connection string which VS 2008 Express generated? I suspect VS 2008
                  express connected to the SQL Server 2005 instance with wrong connect
                  string.
                  >
                  WenYuan -
                  Thanks for answering, and basically, no it's still not fixed. I also had a
                  problem (that's now resolved) with using SQL Server Business Intelligence
                  Development Studio. I uninstalled c# 2008 Express ("orcas") and next time I
                  tried to bring up my import project, it came back with a class not
                  registered. Spent the rest of the day trying to figure that out.

                  I've looked at the connections and the firewall, but what I'm not completely
                  clear on is if c# 2005 Exress can "talk to" Sql Server 2005 or if it HAS to
                  be Sql Server Express. I mentioned that I had changed the DefaultSSEName in
                  the registry to 'ITPETELXP' from 'SQLEXPRESS' (which I don't have running
                  anymore).
                  I still received the error. (ITPETELXP is the name of my machine, by the
                  way) When I go into either SSMS or into Configuration Manager, all the
                  servers are running but they say MSSQLSERVER (not ITPETELXP). When I change
                  the Data Source in the "Advanced" button off the Data Connection dialog to
                  ".\MSSQLSER VER" the error changes to "Error 25 - Connection string is not
                  valid". It still gives me the same drivel about not allowing remote
                  connections, though.

                  The initial connect string is :

                  Data
                  Source=.\ITPETE LXP;AttachDbFil ename=C:\MSSQL$ VSdotNET\Data\h eritage.mdf;Use r
                  ID=sa;Connect Timeout=30;User Instance=True


                  Comment

                  • WenYuan Wang [MSFT]

                    #10
                    Re: Db connect problem

                    Hello Peter
                    Thanks for your reply.

                    I checked the connect string:
                    Data Source=.\ITPETE LXP;

                    Because you did not install SQL express edition on the machine, we cannot
                    define Data Source as ".\ITPETELX P". (It should be "." (which means the
                    default instance))

                    But, the 'Add New Connection' dialog box doesn't give that option. It is a
                    dropdown combo box. It can't be edited. That is a limitation of "Microsoft
                    SQL Server Database File" data source. In VS 2005 professional edition, we
                    can work around this issue by "Microsoft SQL Server" data source.

                    Now, would you please do the following steps to test again?

                    At first, we have to change the SQL Instance which VS express connects to
                    from ".\ITPETELX P" to ".".
                    1)Please click Tools | option | Database Tools | Data Connections
                    2)Remove the string "ITPETELXP" from "SQL Server Instance Name" textbox in
                    the right panel. (Leave it bank)

                    The, please add a new connection again.
                    This time, if you check the connect string, it should be
                    "Source=.;Attac hDbFilename=C:\ MSSQL$VSdotNET\ Data\heritage.m df;User
                    ID=sa;Connect Timeout=30;User Instance=True"

                    * If you received an error message "The user instance login flag is not
                    supported on this version of SQL Server. The connection will be closed",
                    please click "Advanced" button and set "User Instance" property to false.

                    Please try the above method. I think that way should resolve the issue.
                    If the issue still persists, please let me know the connect string and the
                    exact error message. I'll follow up. We are glad to assist you.

                    Hope this helps.
                    Best regards,

                    Wen Yuan
                    Microsoft Online Community Support
                    =============== =============== =============== =====
                    This posting is provided "AS IS" with no warranties, and confers no rights.

                    Comment

                    Working...