Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


SQL Password on connection

Posted on 2008-06-10
Medium Priority
Last Modified: 2013-11-30
Hi all, I have the following that works perfectly fine:

Dim da As New SqlDataAdapter
                Dim conn As SqlConnection = New SqlConnection("Data Source=SQLRPT;Initial Catalog=CorpReports;Persist Security Info=True;async=true;User ID=apps;Password=...")
                Dim cmd As New SqlCommand("hsp_rpt_GrossMargin_Web", conn)

BUT, I want to remove the passwords and use this as a trusted connection, like this:

 Dim da As New SqlDataAdapter
                Dim conn As SqlConnection = New SqlConnection("Data Source=SQLRPT;Initial Catalog=CorpReports;Persist Security Info=True;async=true;Trusted_Connection=Yes")
                Dim cmd As New SqlCommand("hsp_rpt_GrossMargin_Web", conn)

Everything works fine for this when filling a grid or a dropdown or calling for data.  The problem I have is when calling a procedure,  it doesn't seem to want to let me do that.  It runs fine from my local machine, but not from the website.  I have given the server login all the permissions to login to the server and get to all of the Databases.  Like I said, it runs fine to allow me to edit, add or pull data from the databases, but will not allow me to run a procedure...

Question by:ratkinso666
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Expert Comment

ID: 21752567
Try adding Execute permissions to the account the server is using.  I believe it is the ASPNET account on the web server's machine you will need to use.  It may be Network Service, but I think ASPNET is all you need.


Author Comment

ID: 21754993
In the Internet Services Manager???  I have changed everything in there I can see..  I did change it to do scripts and executables.  It still will not run the procedures though...

Accepted Solution

scgstuff earned 2000 total points
ID: 21755269
In the SQL Server Management Studio, set the permission for the DB to allow the accounts to execute.

Right click on the database
Click on Properties
Select Permissions from the list
Add user ASPNET (and you might want to try NT Authority/Network Service if that doesn't do it.)
Scroll down to Execute and check Grant
OK out of it and try again.

If the user does not show up in the pick list when you do this, you may need to:
Go to Security for the SQL Server (also in SSMS)
Right Click on Logins
Select New Login
Search for user and add

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 21759304
OK, I found in the Stored Procedures (SQL 2000 by the way) where to add EXEC in the checkboxes, so I added that to my Web1$, which is our login, added ALL the checkboxes at the database level, which does not include the EXEC, and it still doesn't work...  runs fine from my local machine and my login isn't even in the list at all...


Author Comment

ID: 21759909
Hi Shawn, I have decided to convert the ones that will not work to using connection strings that I will just have a password in the web.config file and that seems to work just fine.  I will just have to manually change that password every 6 months...


Author Closing Comment

ID: 31465784
Thanks for your help Shawn

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question