Sql connection and web services

  • Thread starter Thread starter xxxxyz
  • Start date Start date
X

xxxxyz

Hi,

I want to connect to Sql Server using SqlConnection class using Web
service. I use users from Sql server (I create this users in Sql
Server). And I want to have a sql connection for every connected user
with their user name and password.

How can I organise these connections?
And how use them?

Thanks.
 
Presumably, an extension of this scenario is that your users would be
calling the web service, which would in turn use their user name and
password for access to the SQL Server database.

I'd recommend calling each method, where the user name and password are
passed into the web service. A connection is created and used locally within
that method only. (no session state connections)

The method would essentially:
- construct a connection string form the username and password passed in
- opens the database connection
- pushes or pulls data from the database with this connection
- close the connection again.

The connection string template should be stored in the web configuration
file.

The fact you're having passwords passed to you means you should also use a
secure connection (HTTPS).

Hope that helps.

Daniel.
 
You can use the Session object in an ASP.NET - hosted webservice. Didn't see
the beginning of this post thread, but we should mention that keeping a
connection is session is never a good idea.
Peter
 
Back
Top