Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:04:14+00:00 2026-06-15T14:04:14+00:00

I made a web service that connects to a database hosted in SQL Server

  • 0

I made a web service that connects to a database hosted in SQL Server 2008 R2 on my local computer, and makes some operations on it.

This is the connection string in the web service:

conn = new SqlConnection("Data Source=amir-pc\\SQLEXPRESS;User Id=sa;Password=1234; Initial Catalog=Election;Integrated Security=True");

It works well and successfully accesses the database and runs right.

Now I want to add this web service to IIS.

I successfully added it on Windows 7 to the IIS and can run it from the browser.

localhost/election_service/service.asmx

but when I tried to call a function that checks the connection, it failed, and I don’t know why.
This is the function:

[WebMethod]
    public string Check_conn()
    {
        try
        {
            conn.Open();
            conn.Close();
            return "ok";
        }
        catch 
        {
            return "failed";
        }
    }

Is there any modification I must to do to be able to access the database?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:04:14+00:00Added an answer on June 15, 2026 at 2:04 pm

    Hi can you give more information please try change you code for know what is exception is raising.

    public string dbcheck()
    {
        try
        {
            conn.Open();
            conn.Close();
            return "ok";
        }
        catch (Exception ex)
        {
    
            return ex.Message;
    
        }
    }
    

    Hi, then .. is a login issue:Open IIS Open Application Pool Select your current application pool are you current working (by default is DefaultAppPool) Go to Advanced Options, and find Identity and change to (NT AUTHORITY\Network Service) Then you has been changed your application user, now you need to add permision to network service to database Open SQlMananger, then go to Node Security, rigth click and properties go to NT AUTHORITY\Network Service go to User mapping and add the database you want to allow access.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this web service that returns a datatable from sql server db. Can
I made an android application which connects to a local web service on my
I have a web service that exposes operations to and from a database. I'm
I made a WPF example that consumes a web service ( www.webservicex.com/globalweather.asmx ) in
I made a Web service in which I have a function to count some
I have created a timeclock application in C# that connects to a web service
From the web app, calls are made to a web service that in turn
I have an XML web service that javascript calls are made using jQuery. This
Have a web service that implements REST (sort of) , Client request is made
I made an android application that brings information using a web service, then when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.