Results 1 to 2 of 2

Thread: Using osql

  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Unhappy Unanswered: Using osql

    I am trying to add a login to my local SQL server (MSDE) for an ASP.NET client application. Using osql, I login to the server and enter the following:

    EXEC sp_addlogin [machinename\ASPNET]
    EXEC sp_grantlogin [machinename\ASPNET]

    This doesn't work as my .NET client application fails due to a login failure. What am I doing wrong? Since I get no response from either of these commands, I don't know if they were accepted or not. Any help appreciated.

    Royce

  2. #2
    Join Date
    Dec 2001
    Location
    Canada
    Posts
    45

    Re: Using osql

    I use a store procedure for create my user... like this :

    CREATE PROCEDURE my_create_login(
    @dbname varchar(100),
    @logname varchar(100),
    @logpass varchar(100)
    )

    AS
    SET NOCOUNT ON

    -- DROP LOGIN --
    IF EXISTS (select * from [master].[dbo].[sysxlogins] where name = @logname)
    BEGIN
    IF EXISTS (select * from sysusers where name= @logname)
    BEGIN
    EXEC sp_revokedbaccess @logname
    END
    EXEC sp_droplogin @logname
    END

    -- CREATE APPLICATION USER --
    EXEC sp_addlogin @loginame = @logname,
    @passwd = @logpass,
    @defdb = @dbname

    -- GRANT ACCESS TO DATABASE FOR USER --
    EXEC sp_grantdbaccess @logname

    SET NOCOUNT OFF
    GO
    Franky
    FBoucheros@hotmail.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •