Sql connection and web services

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xxxxyz@abv.bg

    Sql connection and web services

    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.

  • Dan Bass

    #2
    Re: Sql connection and web services

    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.

    <xxxxyz@abv.b g> wrote in message
    news:1111650372 .606734.220310@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    > 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.
    >[/color]


    Comment

    • xxxxyz@abv.bg

      #3
      Re: Sql connection and web services

      Thanks.

      I would like to know if there is any possility for using sessions?

      Comment

      • Peter Bromberg [C# MVP]

        #4
        Re: Sql connection and web services

        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

        <xxxxyz@abv.b g> wrote in message
        news:1111749707 .044858.101610@ o13g2000cwo.goo glegroups.com.. .[color=blue]
        > Thanks.
        >
        > I would like to know if there is any possility for using sessions?
        >[/color]


        Comment

        • Peter Bromberg [C# MVP]

          #5
          Re: Sql connection and web services

          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

          <xxxxyz@abv.b g> wrote in message
          news:1111749707 .044858.101610@ o13g2000cwo.goo glegroups.com.. .[color=blue]
          > Thanks.
          >
          > I would like to know if there is any possility for using sessions?
          >[/color]


          Comment

          Working...