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. General Programming
  3. C#
  4. SQL CONNECTION

SQL CONNECTION

Scheduled Pinned Locked Moved C#
databasesysadminhostingtoolsquestion
6 Posts 2 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
    kibromg
    wrote on last edited by
    #1

    Hi all, when i run my application on a local PC to connect to SQL which is installed Locally i use the following config file. <configuration>    <sqlServer>CelData</sqlServer>    <sqlDatabase>mydatabase</sqlDatabase>    <sqlUser>test</sqlUser>    <sqlPassword>test</sqlPassword>    <sqlTrusted>False</sqlTrusted> </configuration> However ,now i would like to connect to a database on remote PC (with different IP address).When i Run the application locally i would like to connect to the other server that is hosting the database. How would i change the above script so that the database is going to be the one on the remote server? Please advice. Thank you in advance.

    H 1 Reply Last reply
    0
    • K kibromg

      Hi all, when i run my application on a local PC to connect to SQL which is installed Locally i use the following config file. <configuration>    <sqlServer>CelData</sqlServer>    <sqlDatabase>mydatabase</sqlDatabase>    <sqlUser>test</sqlUser>    <sqlPassword>test</sqlPassword>    <sqlTrusted>False</sqlTrusted> </configuration> However ,now i would like to connect to a database on remote PC (with different IP address).When i Run the application locally i would like to connect to the other server that is hosting the database. How would i change the above script so that the database is going to be the one on the remote server? Please advice. Thank you in advance.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Take a look at connectionstrings.com[^], it has the correct information for most scenarios.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      K 1 Reply Last reply
      0
      • H Henry Minute

        Take a look at connectionstrings.com[^], it has the correct information for most scenarios.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

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

        Thanks very much Henry.Its Much appreciated.I have tried to get around it.However it doesnt have something related to the one i am using the XMl data to get a connection to a database. Any Help in relation to the one i am using Please?

        H 1 Reply Last reply
        0
        • K kibromg

          Thanks very much Henry.Its Much appreciated.I have tried to get around it.However it doesnt have something related to the one i am using the XMl data to get a connection to a database. Any Help in relation to the one i am using Please?

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          The XML that you are using simply breaks the connectionstring into its various parts. So the <sqlServer>CelData</sqlServer> line in your XML is the same as the Server=myServerName\theInstanceName; part in the examples on that site. The other parts of your XML, similarly match the other parts of the example (Database=, Trusted_Connection= etc.). You just have to use a little logic to work out which bit matches which part of the XML.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          K 1 Reply Last reply
          0
          • H Henry Minute

            The XML that you are using simply breaks the connectionstring into its various parts. So the <sqlServer>CelData</sqlServer> line in your XML is the same as the Server=myServerName\theInstanceName; part in the examples on that site. The other parts of your XML, similarly match the other parts of the example (Database=, Trusted_Connection= etc.). You just have to use a little logic to work out which bit matches which part of the XML.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

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

            Sorry Henry ,I have tried to come up with it still got some error. Can you please give me a hint of one Connection string similar to the one below.    <sqlServer>ServerName</sqlServer>    <sqlDatabase></sqlDatabase>    <sqlUser>sa</sqlUser>    <sqlPassword>^1^g1xgwZxejDBJqb8FWQXYeQ==</sqlPassword>    <sqlTrusted>False</sqlTrusted>    <fileaccessDomain>c3</fileaccessDomain>    <fileaccessUserName>Daniel</fileaccessUserName>    <fileaccessUserPassword>^1^Rg+/IaL/Xa1KfZLSuaLN0Q==</fileaccessUserPassword>    <ServerRoot>\\test\test\</ServerRoot>    <VirtualRoot>BangRoot\</VirtualRoot>    <FileFTPSite>BangMedia</FileFTPSite>    <Folder>Operator Pictures</Folder>

            H 1 Reply Last reply
            0
            • K kibromg

              Sorry Henry ,I have tried to come up with it still got some error. Can you please give me a hint of one Connection string similar to the one below.    <sqlServer>ServerName</sqlServer>    <sqlDatabase></sqlDatabase>    <sqlUser>sa</sqlUser>    <sqlPassword>^1^g1xgwZxejDBJqb8FWQXYeQ==</sqlPassword>    <sqlTrusted>False</sqlTrusted>    <fileaccessDomain>c3</fileaccessDomain>    <fileaccessUserName>Daniel</fileaccessUserName>    <fileaccessUserPassword>^1^Rg+/IaL/Xa1KfZLSuaLN0Q==</fileaccessUserPassword>    <ServerRoot>\\test\test\</ServerRoot>    <VirtualRoot>BangRoot\</VirtualRoot>    <FileFTPSite>BangMedia</FileFTPSite>    <Folder>Operator Pictures</Folder>

              H Offline
              H Offline
              Henry Minute
              wrote on last edited by
              #6

              You have overcomplicated things. Pretty much all that you should have to do is change the <sqlServer> name, assuming that the databasename is the same, and the sqlPassword and sqlUser, if they are different. Something like this: <pre> <configuration>    <sqlServer>RemoteServerName\SQLInstanceName</sqlServer>    <sqlDatabase>Name of the Database you want on that server</sqlDatabase>    <sqlUser>sa</sqlUser>    <sqlPassword>^1^Rg+/IaL/Xa1KfZLSuaLN0Q==</sqlPassword>    <sqlTrusted>False</sqlTrusted> </configuration></pre> where RemoteServerName, is the name of the remote server machine (or, I believe, its' IP Address. and SQLInstanceName is the name of the SqlServer Instance on that machine. e.g. on my local machine SQLInstanceName would be SQLExpress, because that is what I named it when I installed it.

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              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