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. accessing database using webservice

accessing database using webservice

Scheduled Pinned Locked Moved C#
database
3 Posts 3 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.
  • R Offline
    R Offline
    ronin1770
    wrote on last edited by
    #1

    wanna explore this any sample code for this topic..... thanx in advance

    K P 2 Replies Last reply
    0
    • R ronin1770

      wanna explore this any sample code for this topic..... thanx in advance

      K Offline
      K Offline
      Kodanda Pani
      wrote on last edited by
      #2

      Hi ronin, You can access the database from the webservice in the same way you access from the other applications. The following lines of code connect to the database and return the results in the form of a dataset. [WebMethod] public DataSet GetData() { SqlConnection conn = new SqlConnection(); string connstring = "Persist Security Info=false; Integrated Security =false; database=DATABASENAME; server=DATABASESERVERNAME; User ID=USERID; Password=PASSWORD"; conn.ConnectionString = connstring; DataSet ds = new DataSet("Employee Data Set"); SqlDataAdapter adptr = new SqlDataAdapter("select * from TABLE NAME", connstring); adptr.Fill(ds); return ds; } Hope this will help you. Regards SGS

      1 Reply Last reply
      0
      • R ronin1770

        wanna explore this any sample code for this topic..... thanx in advance

        P Offline
        P Offline
        padvit
        wrote on last edited by
        #3

        The above reply seems to be fine I would like to add some details. Please do take care connection string settings and securtiy Padvit

        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