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. How to Connect to a Remote Database from a WebService?

How to Connect to a Remote Database from a WebService?

Scheduled Pinned Locked Moved C#
databasetutorialquestion
3 Posts 3 Posters 1 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.
  • H Offline
    H Offline
    humblepgmr
    wrote on last edited by
    #1

    Hi THere, as the subject says, I'm writing a webservice and would like to connect to a database. [WebMethod] public ClientData[] GetClientData(int Number){ } I'm not sure how to connect. Can someone please let me know the steps required to connect to a Remote database? Thanks

    R P 2 Replies Last reply
    0
    • H humblepgmr

      Hi THere, as the subject says, I'm writing a webservice and would like to connect to a database. [WebMethod] public ClientData[] GetClientData(int Number){ } I'm not sure how to connect. Can someone please let me know the steps required to connect to a Remote database? Thanks

      R Offline
      R Offline
      RameshwerE
      wrote on last edited by
      #2

      It is just like connecting to a remote database from your application means in the connection string you have to give the database systemname on which system it is deployed ,like its systemname or IP address. For example in ur connection string u have provide the parametres like Sqlconnection _connetcion=new sqlconnection("Server=SystemName;Initial Catalog=DatabaseName;User Id=sa; Password=;") I hope this will works for you. More over give this connection strings in your web.config file so that you can refer it all over the function and mainatainace will be easier if your database is moved to other systems in the future. Sorry for my poor english :) Happy programming. Cheers,

      1 Reply Last reply
      0
      • H humblepgmr

        Hi THere, as the subject says, I'm writing a webservice and would like to connect to a database. [WebMethod] public ClientData[] GetClientData(int Number){ } I'm not sure how to connect. Can someone please let me know the steps required to connect to a Remote database? Thanks

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Connecting to a database from a web service shouldn't be any different than a regular app.

        "Find it your bloody self - immediately!" - Dave Kreskowiak

        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