VB Script & connection strings & passwords

  • Hi all

    wonder if you can help me............

    We run some VB scripts to extract data from our SQL server. Within these scripts we reference a 'read only' SQL userid and it's password in the connection string.

    What I want to do is remove the references to the 'read only' user and it's password from the scripts.

    Could we add the user that is running the script as a SQL authenticated user (that has read only access) thereby not have to reference any passwords in our script ?

    Thanks for any help.

  • Two options, if you want to use SQL authentication and pass in a username and password you would need build the connection string dynamically. Saves storing the username and password in the VBScript

    Or

    Switch to trusted connection using your windows account for authentication

    Something like

    <%

    'declare the variable that will hold the connection string

    Dim ConnectionString

    'define connection string, specify database driver and location of the database

    ConnectionString="Driver={SQLServer};Server=your_server_name;" &_

    "Database=your_database_name;Trusted_Connection=yes;"

    %>

  • Hi - thanks for the prompt(!) reply.

    Yes I didn;t ask about windows authentication. So really we could add the user that is running the vb script as a windows authenticated user to SQL and not have to explicitly reference any passwords in our scripts? (our server ia VM on a farm so not entirely sure whether windows authentication is allowed).

  • Correct, if your server allows Windows authentication that's the better option.

    Otherwise your talking about adding 2 parameters to the script to prompt for username and password then using them to build a dynamic connection string.

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

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