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. Web Development
  3. ASP.NET
  4. Help in ASP.NET web service

Help in ASP.NET web service

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelpasp-netsql-server
6 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.
  • A Offline
    A Offline
    akosidandan
    wrote on last edited by
    #1

    Hello experts, I would like to ask again if how will I'm going to edit my web services because it seems that it's only working on my local machine. I tried to upload my web service and the 2 database(ms access 2003 and sql server 2005 express) to a free asp.net hosting site but I got and error that I cant access the database. I detach my sql server 2005 express to my sqlSERVER Management studio before I upload it. Below is my sample code to my asmx file.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;

    //sql client import

    using System.Data.SqlClient;
    using System.Data;

    using System.Data.OleDb;

    namespace WebService1
    {
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    //[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //[System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        \[WebMethod\]
        public DataTable getData()
        {
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\\\MemberSites\\\\MemberSites\_AspSpider\_Info\\\\akosiDAN\\\\database\\\\Database1.mdb");
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.Tables.Add(dt);
    
            OleDbDataAdapter da = new OleDbDataAdapter ("Select \* from phonebooktable",con);
            da.Fill (dt);
    
            return dt;
        }
    
        \[WebMethod\]
        public DataTable getData()
        {
            SqlConnection con = new SqlConnection("server= DANDAN-PC\\\\SQLEXPRESS;uid=myID;pwd=myPASSWORD;database=phonebookdatabase");
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            ds.Tables.Add(dt);
    
            SqlDataAdapter da = new SqlDataAdapter("Select \* from phonebooktable", con);
    
            da.Fill(dt);
    
            return dt;
        }
    }
    

    }

    Any help are kindly appreciated. Thanks, DAN

    P P 2 Replies Last reply
    0
    • A akosidandan

      Hello experts, I would like to ask again if how will I'm going to edit my web services because it seems that it's only working on my local machine. I tried to upload my web service and the 2 database(ms access 2003 and sql server 2005 express) to a free asp.net hosting site but I got and error that I cant access the database. I detach my sql server 2005 express to my sqlSERVER Management studio before I upload it. Below is my sample code to my asmx file.

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.Services;

      //sql client import

      using System.Data.SqlClient;
      using System.Data;

      using System.Data.OleDb;

      namespace WebService1
      {
      /// <summary>
      /// Summary description for Service1
      /// </summary>
      //[WebService(Namespace = "http://tempuri.org/")]
      //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      //[System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
      // [System.Web.Script.Services.ScriptService]
      public class Service1 : System.Web.Services.WebService
      {

          \[WebMethod\]
          public DataTable getData()
          {
              OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\\\MemberSites\\\\MemberSites\_AspSpider\_Info\\\\akosiDAN\\\\database\\\\Database1.mdb");
              DataSet ds = new DataSet();
              DataTable dt = new DataTable();
              ds.Tables.Add(dt);
      
              OleDbDataAdapter da = new OleDbDataAdapter ("Select \* from phonebooktable",con);
              da.Fill (dt);
      
              return dt;
          }
      
          \[WebMethod\]
          public DataTable getData()
          {
              SqlConnection con = new SqlConnection("server= DANDAN-PC\\\\SQLEXPRESS;uid=myID;pwd=myPASSWORD;database=phonebookdatabase");
              DataSet ds = new DataSet();
              DataTable dt = new DataTable();
              ds.Tables.Add(dt);
      
              SqlDataAdapter da = new SqlDataAdapter("Select \* from phonebooktable", con);
      
              da.Fill(dt);
      
              return dt;
          }
      }
      

      }

      Any help are kindly appreciated. Thanks, DAN

      P Offline
      P Offline
      Pravin Patil Mumbai
      wrote on last edited by
      #2

      This does not seem to be a problem of Web service. Check the Database credentials. Is database set up properly? Does the user have rights to read, write database. Hope this helps. All the best.

      A 2 Replies Last reply
      0
      • P Pravin Patil Mumbai

        This does not seem to be a problem of Web service. Check the Database credentials. Is database set up properly? Does the user have rights to read, write database. Hope this helps. All the best.

        A Offline
        A Offline
        akosidandan
        wrote on last edited by
        #3

        Hello, Thanks for the reply, before I upload it to the hosting site detach my sql server database and I used to connect it using sql authentication. For the ms access database I think I set it up correctly. I tried commenting out the block of code using sql server but I still get an error. I tried the web service in my localhost and it works fine but when I tried to upload it I cant seem to make it work. Below is the hosting site where I tried to upload my web service, I tried to follow it as on what they say for the connectionstring http://www.aspspider.com/tips/Tip18.aspx[^] Any help are kindly appreciated. Thanks, DAN

        1 Reply Last reply
        0
        • A akosidandan

          Hello experts, I would like to ask again if how will I'm going to edit my web services because it seems that it's only working on my local machine. I tried to upload my web service and the 2 database(ms access 2003 and sql server 2005 express) to a free asp.net hosting site but I got and error that I cant access the database. I detach my sql server 2005 express to my sqlSERVER Management studio before I upload it. Below is my sample code to my asmx file.

          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Web;
          using System.Web.Services;

          //sql client import

          using System.Data.SqlClient;
          using System.Data;

          using System.Data.OleDb;

          namespace WebService1
          {
          /// <summary>
          /// Summary description for Service1
          /// </summary>
          //[WebService(Namespace = "http://tempuri.org/")]
          //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
          //[System.ComponentModel.ToolboxItem(false)]
          // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
          // [System.Web.Script.Services.ScriptService]
          public class Service1 : System.Web.Services.WebService
          {

              \[WebMethod\]
              public DataTable getData()
              {
                  OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\\\MemberSites\\\\MemberSites\_AspSpider\_Info\\\\akosiDAN\\\\database\\\\Database1.mdb");
                  DataSet ds = new DataSet();
                  DataTable dt = new DataTable();
                  ds.Tables.Add(dt);
          
                  OleDbDataAdapter da = new OleDbDataAdapter ("Select \* from phonebooktable",con);
                  da.Fill (dt);
          
                  return dt;
              }
          
              \[WebMethod\]
              public DataTable getData()
              {
                  SqlConnection con = new SqlConnection("server= DANDAN-PC\\\\SQLEXPRESS;uid=myID;pwd=myPASSWORD;database=phonebookdatabase");
                  DataSet ds = new DataSet();
                  DataTable dt = new DataTable();
                  ds.Tables.Add(dt);
          
                  SqlDataAdapter da = new SqlDataAdapter("Select \* from phonebooktable", con);
          
                  da.Fill(dt);
          
                  return dt;
              }
          }
          

          }

          Any help are kindly appreciated. Thanks, DAN

          P Offline
          P Offline
          Prasanta_Prince
          wrote on last edited by
          #4

          Check the connection string of the MDB file. Try to use Server.Mappath() .

          A 1 Reply Last reply
          0
          • P Pravin Patil Mumbai

            This does not seem to be a problem of Web service. Check the Database credentials. Is database set up properly? Does the user have rights to read, write database. Hope this helps. All the best.

            A Offline
            A Offline
            akosidandan
            wrote on last edited by
            #5

            Hello, I fix now the problem it seems that one causing the error is the bin file of my webservice. I notice that although I edit the code of my asmx file and even if its a working but if I did not re upload the the bin file of my webservice.The website still load the past code of my asmx rather than the new one. Thanks everyone, DAN

            1 Reply Last reply
            0
            • P Prasanta_Prince

              Check the connection string of the MDB file. Try to use Server.Mappath() .

              A Offline
              A Offline
              akosidandan
              wrote on last edited by
              #6

              Hello, I fix now the problem it seems that one causing the error is the bin file of my webservice. I notice that although I edit the code of my asmx file and even if its a working but if I did not re upload the the bin file of my webservice.The website still load the past code of my asmx rather than the new one. Thanks also for the server.mappath if was a great help to map the path of my files. Thanks everyone, DAN

              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