Creating a new SQL2005 Expr. user account from a program

  • Hi,

    I developed an application (Visual Basic 6) and I need to create a SQL2005 Express user account with administrative privileges.

    This application correctly creates the database and also the DSN connection.

    Unfortunately if I connect to the database with "Windows Authentication mode" and the Windows login account is NOT member of the Administrators group but is, for instance, Users, I can't connect to the database.

    I'm able to connect the database only if the Windows account is a member of the Administrators group.

    Then I thought to create a SQL2005 user account with no restrictions and then use it from "inside" the program to connect the database (passing the UID and PWD as parameters in the connection string), setting the "Authentication Mode" to "SQL Server".

    The program , then, will follow those steps:

    - at first creation of the database (always with a Windows administrator user account)

    - creation of the SQL user account with no restrictions

    - program restarts

    after the program has restarted, the connection string will include also the user ID and password of the SQL user account previously created and the database will be connected.

    This is what I would like to do.

    Now what I tried with no success.

    I created a SQL "login account" using

    CREATE LOGIN prova PASSWORD 'prova123prova'

    then

    CREATE USER prova FOR LOGIN prova

    and then

    GRANT ALL TO prova

    I opened "SQL Server Management Studio Express" (using Windows Authentication) and I found the account "prova" but if I try to reconnect using the "SQL Server Authentication" and typing "prova", "prova123prova" as username and password an error message appears:

    Unable to connect to TP077\CSERV

    A connection was succesfully established with a server, but then an error occurred during the login process.(provider: Shared Memory Provider, error:0 - no process to the other side of the pipe.)(Micorsoft SQL Server, error: 233)

    (Consider that I translated the error message in english so the content may not be exactly like the original message in english).

    How that account, then, must be created using SQL commands?

    Thank you.

    Regards,

    Roberto

  • use

    CREATE LOGIN prova WITH PASSWORD = 'prova123prova'

    my guess is the password is not being recognised

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Yes, you were right, the password was not recognized because I created the password specifying it between quotes 'prova123prova' then SQL2005 considered also quotes as being part of the password (I was typing it without quotes then that was the reason of the error popup message).

    Anyway...I found another way to access the database without creating accounts.

    If I install SQL2005 with command line parameters "SECURITYMODE=SQL" and "SAPWD=prova123prova" it assigns that password to the built-in "sa" account, then from inside my program every operation is done using "User ID=sa" and "Password=prova123prova" and everything worked out.

    I hope this it's useful.

    Regards,

    Roberto

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply