[web] Accessing a Database from a Web Service?

Started by
0 comments, last by paulecoyote 18 years, 10 months ago
Hello! Im quite new on this topic and is writing a very simple web service witch is containing three Web Methods. One is the predefined Hello World that is autogenerated(just to test if any of the functions is working) and the two remaining is for getting information from a database, using a few Stored Procedures that I have written. I have made a SQL Server(using MS SQL Server 2000 Evaluation), IIS, then I made a database from the Server Explorer in VisualStudio.Net, made a table, and stored some information in it. Then I made a Data Set of it, for use in my Classes. I write in C#. Then I added this Web Service, and tried to run it using only the method that was auto genereated(Hello World) and everything went well when I pushed "Invoke". Then I made some precdures that was going to access my database, using a stored procedure for selecting all information in the table. And tried to run it, everything went well, except for the two new procedures, So I made some changes in Web.config: <add key="ConnectionString" value="Integrated Security=SSPI;database=TestDatabase;server=localhost"/> for using Integrated Security and <identity impersonate="true" userName="" password="" /> When the configuration is like this I get access to the web service, the HelloWorld is working but when I push Invoke on the two methods that should access the database, I get: "This page could not be dispalyed""HTTP 500 Internal server error" but if I place a username/password in the config.web i get this error before the web methods that the web service contains get listed: "Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Unspecified error '" What username and password are requred here? Why am I getting "This page cannot be displayed" ehrn I push Invoke on the database methods? Hope the problem was made clear and that somebody can help me, if there are any questions about me problem, please ask =) Thanks in advance
Advertisement
there are a couple of different ways to authenticate against sql server... you probably want to use the old way rather then the windows authentication based way.
You set this on SQL Server itself.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.

This topic is closed to new replies.

Advertisement