Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to connect remote sql server(within LAN) using ADO?

How to connect remote sql server(within LAN) using ADO?

Scheduled Pinned Locked Moved Database
databasesysadmintutorialquestionsql-server
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kcynic
    wrote on last edited by
    #1

    I want to connect to the sql server database and do some query command via ado. I use this connection string to do that work:"Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DaDian2008;Data Source=localhost;UID=sa;PWD=123456;Network Library=dbmssocn", it works well. But how about with a remote server(LAN). For example, my ip address is 192.168.1.100, i just replace localhost to 192.168.1.100, it would get an exception says: Code = 80004005 Code meaning = Unspecified error Source = Microsoft OLE DB Provider for SQL Server Description = [DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found. Why? And how can i connect to a remote sql server(MS SQL Server within LAN)? btw, if I use "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008; Then, I can connect to the database on my locale computer, but it would fail again on another computer.

    M T S 3 Replies Last reply
    0
    • K kcynic

      I want to connect to the sql server database and do some query command via ado. I use this connection string to do that work:"Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DaDian2008;Data Source=localhost;UID=sa;PWD=123456;Network Library=dbmssocn", it works well. But how about with a remote server(LAN). For example, my ip address is 192.168.1.100, i just replace localhost to 192.168.1.100, it would get an exception says: Code = 80004005 Code meaning = Unspecified error Source = Microsoft OLE DB Provider for SQL Server Description = [DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found. Why? And how can i connect to a remote sql server(MS SQL Server within LAN)? btw, if I use "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008; Then, I can connect to the database on my locale computer, but it would fail again on another computer.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      You need the name/IP address of the server you want to connection to. localhost - 192.168.1.100 and your computer name are all pointing the the instance of SQL server installed on your machine.

      Never underestimate the power of human stupidity RAH

      K 1 Reply Last reply
      0
      • M Mycroft Holmes

        You need the name/IP address of the server you want to connection to. localhost - 192.168.1.100 and your computer name are all pointing the the instance of SQL server installed on your machine.

        Never underestimate the power of human stupidity RAH

        K Offline
        K Offline
        kcynic
        wrote on last edited by
        #3

        Thanks for your reply. But my real problem is that, how to connect to a remote ms sql server(within LAN)?

        M 1 Reply Last reply
        0
        • K kcynic

          Thanks for your reply. But my real problem is that, how to connect to a remote ms sql server(within LAN)?

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          And the answer is to find out the name/IP Address of the server you wish to connect to and use that in the connection string. I assume you have the database set up with credentials on the other server!

          Never underestimate the power of human stupidity RAH

          K 1 Reply Last reply
          0
          • M Mycroft Holmes

            And the answer is to find out the name/IP Address of the server you wish to connect to and use that in the connection string. I assume you have the database set up with credentials on the other server!

            Never underestimate the power of human stupidity RAH

            K Offline
            K Offline
            kcynic
            wrote on last edited by
            #5

            Oh, I use my computer as sql server, the code which useing "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008" works well on my own computer, but doesn't on another computer.

            M 1 Reply Last reply
            0
            • K kcynic

              Oh, I use my computer as sql server, the code which useing "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008" works well on my own computer, but doesn't on another computer.

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              kcynic wrote:

              192.168.1.100

              This is a local IP, the other machine is looking for SQL on their machine, not yours. You might try replacing that with a machine name or find out your lan IP. I am presuming you want to use your machine as the SQL server.

              Never underestimate the power of human stupidity RAH

              K 1 Reply Last reply
              0
              • M Mycroft Holmes

                kcynic wrote:

                192.168.1.100

                This is a local IP, the other machine is looking for SQL on their machine, not yours. You might try replacing that with a machine name or find out your lan IP. I am presuming you want to use your machine as the SQL server.

                Never underestimate the power of human stupidity RAH

                K Offline
                K Offline
                kcynic
                wrote on last edited by
                #7

                But, 192.168.1.100 is the real local IP of mine and i do want to use my machine as the SQL server. You meant, I should replace Server=192.168.1.100 with Server=MyPcName? But, if so, to a client witch knew its server ip only, how should it configure this argument? Unfortunely, if it's not a practice but a C/S product, one of its user is a orgnization with a plenty of members,they all need to install the client program, so they configure the Server argument with their server's correct name. And for another group, they have to do the similar work! In another words, the installation can't be done automately! right?

                M 1 Reply Last reply
                0
                • K kcynic

                  But, 192.168.1.100 is the real local IP of mine and i do want to use my machine as the SQL server. You meant, I should replace Server=192.168.1.100 with Server=MyPcName? But, if so, to a client witch knew its server ip only, how should it configure this argument? Unfortunely, if it's not a practice but a C/S product, one of its user is a orgnization with a plenty of members,they all need to install the client program, so they configure the Server argument with their server's correct name. And for another group, they have to do the similar work! In another words, the installation can't be done automately! right?

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #8

                  You need to define your requirements Are you on a LAN with all the clients How many clients Is you machine the dev box Do you have a UAT server or even a database Do you have a production server/ddatabase Do you have an IT department, b/c if you are it you are in deep do do.

                  Never underestimate the power of human stupidity RAH

                  K 1 Reply Last reply
                  0
                  • M Mycroft Holmes

                    You need to define your requirements Are you on a LAN with all the clients How many clients Is you machine the dev box Do you have a UAT server or even a database Do you have a production server/ddatabase Do you have an IT department, b/c if you are it you are in deep do do.

                    Never underestimate the power of human stupidity RAH

                    K Offline
                    K Offline
                    kcynic
                    wrote on last edited by
                    #9

                    Oh, there are the answers: 1. All clients within a LAN. 2. My pc is a dev box 3. I have MS SQL Server 2005 installed. 4. Of course no product. I just took that as a example 5. Im not a web developer, so b/s has no help for me. No matter how many clients would be, i just only want to know how. Thanks

                    1 Reply Last reply
                    0
                    • K kcynic

                      I want to connect to the sql server database and do some query command via ado. I use this connection string to do that work:"Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DaDian2008;Data Source=localhost;UID=sa;PWD=123456;Network Library=dbmssocn", it works well. But how about with a remote server(LAN). For example, my ip address is 192.168.1.100, i just replace localhost to 192.168.1.100, it would get an exception says: Code = 80004005 Code meaning = Unspecified error Source = Microsoft OLE DB Provider for SQL Server Description = [DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found. Why? And how can i connect to a remote sql server(MS SQL Server within LAN)? btw, if I use "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008; Then, I can connect to the database on my locale computer, but it would fail again on another computer.

                      T Offline
                      T Offline
                      T2102
                      wrote on last edited by
                      #10

                      Depending on whether you use C++ or VB, the connection string is slightly different. Look at connectionstrings.com . Also, you should first make sure that you can connect with C:\WINDOWS\system32\odbcad32.exe before playing with your code.

                      K 1 Reply Last reply
                      0
                      • T T2102

                        Depending on whether you use C++ or VB, the connection string is slightly different. Look at connectionstrings.com . Also, you should first make sure that you can connect with C:\WINDOWS\system32\odbcad32.exe before playing with your code.

                        K Offline
                        K Offline
                        kcynic
                        wrote on last edited by
                        #11

                        Oh, thanks for you reply, i think i got the answer from that page.

                        1 Reply Last reply
                        0
                        • K kcynic

                          I want to connect to the sql server database and do some query command via ado. I use this connection string to do that work:"Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DaDian2008;Data Source=localhost;UID=sa;PWD=123456;Network Library=dbmssocn", it works well. But how about with a remote server(LAN). For example, my ip address is 192.168.1.100, i just replace localhost to 192.168.1.100, it would get an exception says: Code = 80004005 Code meaning = Unspecified error Source = Microsoft OLE DB Provider for SQL Server Description = [DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found. Why? And how can i connect to a remote sql server(MS SQL Server within LAN)? btw, if I use "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008; Then, I can connect to the database on my locale computer, but it would fail again on another computer.

                          S Offline
                          S Offline
                          slam Iqbal
                          wrote on last edited by
                          #12

                          Identify what is your problem. Is that Network problem or SQL Server problem or both? You are using LAN so test these: 1. Try ping command to/from server & clients’ PCs. (y/n?) 2. Or try file or printer sharing among PCs. If you failed all above tests, you have Network problem. Otherwise you are facing the problem to connect with SQL Server. All Mycroft Holmes’s discussions are about Network problem without being sure what the problem is. I’m waiting to know what your problem is.

                          E 1 Reply Last reply
                          0
                          • S slam Iqbal

                            Identify what is your problem. Is that Network problem or SQL Server problem or both? You are using LAN so test these: 1. Try ping command to/from server & clients’ PCs. (y/n?) 2. Or try file or printer sharing among PCs. If you failed all above tests, you have Network problem. Otherwise you are facing the problem to connect with SQL Server. All Mycroft Holmes’s discussions are about Network problem without being sure what the problem is. I’m waiting to know what your problem is.

                            E Offline
                            E Offline
                            Elangovan Ayyandurai
                            wrote on last edited by
                            #13

                            Hi... i dont have any network problem but still i'm not able to connect to MS SQL Server which is in another system of my LAN.... Please provide me what to chect wit SQl server and Connection string... pLZZZZZZZZ.......

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups